Using VC + + to develop PHP extension considerations _php Tutorial

Source: Internet
Author: User
First, by default, C + + is using. cpp as the extension, and PHP is written in C, so you must use C + + to provide the specified symbol extern "C" for the exchange to solve the problem, the following two parts of the statement must be included:
extern "C" {
#include "Php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
...//other C header files
}
And
extern "C" {
#ifdef Compile_dl_myext
Zend_get_module (Myext)
#endif
}
Second, the STL template definition is not included in the C connection Exchange specifier, and PHP needs to math.h this header file, so the compile time will produce MATH.H (514) Error c2894:templates cannot is declared to has ' C ' linkage error message, to solve this problem, you need to add the following code before your CPP file header, which is the extern "C" connector:
#ifdef WIN32
#include
#endif
Three, same as C, must first declare all function prototypes in the header file, such as: php_myext.h), if the header file is not used, it must be in the CPP file (such as: Ext.cpp) Zend All function prototypes are declared between the functions structure, that is, before the following code:
Function_entry myext_functions[] = {
Php_fe (confirm_myext_compiled, NULL)/* For testing, remove later. */
{null, NULL, NULL}
};

http://www.bkjia.com/phpjc/589781.html www.bkjia.com true http://www.bkjia.com/phpjc/589781.html techarticle A, by default, C + + is using. cpp as the extension, and PHP is written in C, so you must use C + + Provides a C connection to swap the specified symbol extern "C" To resolve this problem, the following two parts ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.