Hi, I've just completed some local php extensions using VC++. Here are some notes that might help others when creating php extensions using VC++.
By default, Visual C++ will add classes with a .cpp extension. To make this work properly, you must either wrap the C specific sections, or force C linkage. The sections that must be wrapped are: extern "C" { #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" } and extern "C" { #ifdef COMPILE_DL_MYMODULE ZEND_GET_MODULE(MyModule) #endif } To force C-linkage, you can change the extension to .c, or add /Tc to your settings (Project > Setting > C/C++ >General - then add /Tc to the "Project Options" at the bottom). Second, you should add this to the very top of your cpp file: #ifdef WIN32 #include <math.h> #endif Otherwise, the math header will be included inside the extern "C" section, and will cause an error. (STL template definitions can't be included under the "C" linkage.) Third, be sure to declare all function prototypes first. If you don't use a php_MyModule.h file, you _must_ declare all function prototypes before the first zend function struct. So, put them after your header includes, and before the section that looks like: function_entry MyModule_functions[] = { PHP_FE(confirm_MyModule_compiled, NULL) /* For testing, remove later. */ {NULL, NULL, NULL} /* Must be the last line in Cache_functions[] */ }; These were just a few small notes that really helped me in using Visual C++ to build some PHP extensions. Also, the article http://www.devnewz.com/2002/0909.html was very helpful to start from. dave -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php