Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swig和PHP:C函数需要enum作为参数_Php_C_Enums_Swig - Fatal编程技术网

Swig和PHP:C函数需要enum作为参数

Swig和PHP:C函数需要enum作为参数,php,c,enums,swig,Php,C,Enums,Swig,我有一个c函数,如下所示: GetCurrentMode(RADIOMODES *radioModes); my.h文件和swigs.i文件都包含以下枚举定义: typedef enum _RADIOMODES { RADIOMODES_NONE = 0, RADIOMODES_ONE = 1, RADIOMODES_TWO = 2, } RADIOMODES; GetCurrentMode应将$rcs设置为正确的模

我有一个c函数,如下所示:

GetCurrentMode(RADIOMODES *radioModes); 
my.h文件和swigs.i文件都包含以下枚举定义:

typedef enum _RADIOMODES { 
        RADIOMODES_NONE     = 0, 
        RADIOMODES_ONE  = 1, 
        RADIOMODES_TWO    = 2, 
} RADIOMODES; 
GetCurrentMode应将$rcs设置为正确的模式。 但当我跑步时:

$rcs = RADIOMODES_NONE;
GetCurrentMode($rcs); 
我得到以下错误: PHP致命错误:GetCurrentMode的参数1中存在类型错误。预期SWIGTYPE_p_无线电模式

如何让swig和php将$rcs设置为正确的枚举? 或者如何让swig将枚举RADIOMODE转换为int并返回

已解决: 问题是我需要在定义.h文件后添加一个指针函数

%pointer_functions( RADIOMODES, RADIOMODESp )
这增加了几个我可以在PHP中使用的新函数