c++ - Error 'zif_test_addme': undeclared identifier - php extension development -


i new php extension development in windows , following article series learn it:- https://jojokahanding.wordpress.com/2014/05/26/writing-php-extensions-for-windowswriting-the-extension/

i've built compile environment extension development following this article . building successfully. when wrote function in add 2 numeric values , tried build it. throws me error @ line 11 in phptestmodule.php:-

'zif_test_addme': undeclared identifier  

line 11 code :-

  php_fe(test_addme,null) 

why getting error?

i have googled , found this php website , tried replace php_fe zend_fe , end zend_fe_end. didn't work , end getting same error. plz help.

ps :- using visual studio 2017 , php 7.0.22 build extension , system 64 bit.

code snippets:-

phptestmodule.cpp

// phptestmodule.cpp : defines exported functions dll  application. //  #include "stdafx.h"   #define php_test_extname "test" #define php_test_version "1.0.30"  zend_function_entry test_functions[] = {     php_fe(test_addme,null)     {null,null,null} };  zend_module_entry test_module_entry = { #if  zend_module_api_no>=20010901     standard_module_header, #endif     php_test_extname,     test_functions,     null,     null,     null,     null,     null, #if zend_module_api_no>=20010901     php_test_version, #endif     standard_module_properties };  zend_get_module(test);  php_function(test_addme) {     long paramone;     long paramtwo;     if (zend_parse_parameters(zend_num_args() tsrmls_cc, "ll", &paramone, &paramtwo) == failure)     {         return_false;     }     return_long(paramone + paramtwo); } 

stdafx.h

    // stdafx.h : include file standard system include files, // or project specific include files used frequently, // changed infrequently //  #pragma once  #include "targetver.h"  #define win32_lean_and_mean             // exclude rarely-used stuff windows headers // windows header files: #include <windows.h>  #ifdef _debug #define zend_debug 1 #else #define zend_debug 0 #endif  #define zts 1 #define zend_win32 1 #define php_win32 1  #include<math.h> #include<wchar.h> #include<io.h> #include<php.h>  #pragma comment(lib,"php7ts.lib") // todo: reference additional headers program requires here 

you need forward-declare php function binding. can either in header external function or static function in phptestmodule.cpp compilation unit.

make sure use php_function macro did definition.

example

// forward declare php function bindings: static php_function(test_addme);  // define list of functions provided extension module: zend_function_entry test_functions[] = {     php_fe(test_addme,null)     {null,null,null} };  // php function binding definition: php_function(test_addme) {     long paramone;     long paramtwo;     if (zend_parse_parameters(zend_num_args() tsrmls_cc, "ll", &paramone, &paramtwo) == failure)     {         return_false;     }     return_long(paramone + paramtwo); } 

explanation

the php_function macro evaluates normal c function declaration/definition. maps void zif_test_addme(internal_function_parameters) internal_function_parameters macro defining actual arguments required function binding implementation (you don't have worry these). can use in both declaration context or definition. of course, definition declaration have moved implementation of php_function(test_addme) before zend_function_entry declaration.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -