1
我寫了一個非常簡單的PHP擴展。現在我想讓它在啓動時讀入文件。這裏是我的代碼:C++ PHP擴展
#define PHP_COMPILER_ID "VC6"
#include <fstream>
#include "php.h"
int number = 0;
ZEND_FUNCTION(use_html);
//declaration
ZEND_MINIT_FUNCTION(use_html);
zend_function_entry use_functions[] =
{
ZEND_FE(use_html, NULL)
{NULL, NULL, NULL}
};
zend_module_entry use_html_module_entry =
{
STANDARD_MODULE_HEADER,
"First_Extension",
use_functions,
ZEND_MINIT(use_html),
NULL, NULL, NULL, NULL,
"1.0.0-tutorial",
STANDARD_MODULE_PROPERTIES
};
ZEND_GET_MODULE(use_html);
ZEND_FUNCTION(use_html)
{
bool useHtml;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &useHtml) == FAILURE)
{
E_ERROR;
return;
}
if(useHtml)
{
php_printf("This string uses <a href='#'>Html</a>");
}
else
{
int sum = 0;
int i = 0;
for(i;i<100000;i++)
sum += i;
RETURN_LONG(number);
}
return;
}
ZEND_MINIT_FUNCTION(use_html)
{
std::ifstream infile("file.txt");
number++;
return SUCCESS;
}
和錯誤消息是: 錯誤5錯誤C2491: '的std :: ENDL':dllimport的函數定義不允許C:\ Program Files文件\微軟的Visual Studio 10.0 \ VC \包括\ ostream的1004 1 php_extension1
我也試圖改變包括順序,但它沒有幫助。
編輯
這裏是有問題的部分從ostream的
_CRTIMP2_PURE inline basic_ostream<char, char_traits<char> >&
__CLRCALL_OR_CDECL endl(basic_ostream<char, char_traits<char> >& _Ostr)
{ // insert newline and flush byte stream
_Ostr.put('\n');
_Ostr.flush();
return (_Ostr);
}
我沒有看到你的代碼的任何使用std :: ENDL的。發佈使用它的代碼的一部分。 – user1610015
這是我的整個代碼。如果我包含,問題發生。我想它包括ostream,並有問題。 –
user1748124
你記住你的編譯器爲'VC6'但代碼,您發送給我們'的std :: endl'不是'VC6'編譯器,你可以請報告你的PHP和程序通過它內置的編譯器? – BigBoss