Swig错误-错误:输入(2)中的语法错误

Swig error- Error: Syntax error in input(2)

本文关键字:错误 语法 输入 Swig      更新时间:2023-10-16

我一直在尝试为c++库创建一个python包装器。Swig给出了这段代码的错误,我不明白是什么导致了错误。而且我对swig也很陌生。它给我的错误是"输入(2)中的语法错误",也这里是代码的一部分。

typedef void (__cdecl *TSI_FUNCTION_CAMERA_CONTROL_CALLBACK) (int ctl_event, void*context);
typedef void (__cdecl *TSI_FUNCTION_CAMERA_CONTROL_CALLBACK_EX)  (int  ctl_event,      TSI_FUNCTION_CAMERA_CONTROL_INFO *ctl_event_info, void *context);
typedef void (__cdecl *TSI_FUNCTION_IMAGE_NOTIFICATION_CALLBACK) (int  notification,   void *context);
typedef void (__cdecl *TSI_FUNCTION_IMAGE_CALLBACK)  (TsiImage *tsi_image, void *context);
typedef void (__cdecl *TSI_TEXT_CALLBACK_FUNCTION)  (char     *str,           void *context);

SWIG不理解__cdecl。您可能需要添加"%include"窗口。到你的接口文件。你可能有其他符号,没有定义,但从你给我的信息我不能告诉。

%module example
%{
  #include "example_if.h"
%}
...
# Here it must be present
%include "windows.i"
...
%include "example_if.h"