SWIG raise Syntax error - possibly a missing semicolon

35 Views Asked by At

I'm new to SWIG
I'm trying to make a dll wrapper for python

  • Below is the content of the SWING Interface file
%module IviDCPwr
%{
#include <stdarg.h>
#include <limits.h>
#include <sys.types.h>
#include "visatype.h"
#include "visa.h"
#include "ivi.h"
#include "IviVisaType.h"
#include "IviDCPwr.h"
#include "IviDCPwrObsolete.h"
%}
%include "IviDCPwr.h"
  • Below is command I use
.\swig.exe -I"C:/Program Files (x86)/IVI Foundation/IVI/Include" -I"C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Include" -python "IviDCPwr.i"
  • Below is result of the above command
C:\Program Files (x86)\IVI Foundation\IVI\Include\IviDCPwr.h(179) : Error: Syntax error - possibly a missing semicolon (';').
  • Below is the part of IviDCPwr.h
168: #define IVIDCPWR_VAL_TRIG_RTSI_4                            (18L)
169: #define IVIDCPWR_VAL_TRIG_RTSI_5                            (19L)
170: #define IVIDCPWR_VAL_TRIG_RTSI_6                            (20L)
171: 
172: #define IVIDCPWR_VAL_TRIG_SRC_CLASS_EXT_BASE                (500L)
173: #define IVIDCPWR_VAL_TRIG_SRC_SPECIFIC_EXT_BASE             (1000L)
174: 
175: /****************************************************************************
176:  *--------- IviDCPwr Class Instrument Driver Function Declarations ---------*
177:  ****************************************************************************/
178:     /*- Required VXIplug&play Functions -*/
179: ViStatus _VI_FUNC IviDCPwr_init (ViRsrc logicalName, 
180:                                  ViBoolean idQuery, 
181:                                  ViBoolean resetDevice, 
182:                                  ViSession *vi);
183: 
184: ViStatus _VI_FUNC IviDCPwr_close (ViSession vi);
185: 
186: ViStatus _VI_FUNC IviDCPwr_reset (ViSession vi);
187: 
188: ViStatus _VI_FUNC IviDCPwr_self_test (ViSession vi, 
189:                                       ViInt16 *selfTestResult, 
190:                                       ViChar selfTestMessage[]);
191: 
192: ViStatus _VI_FUNC IviDCPwr_error_query (ViSession vi, 
193:                                         ViInt32 *errorCode, 
194:                                         ViChar errorMessage[]);

1

There are 1 best solutions below

0
Criminal_Affair_At_SO On

This is most likely caused by the _VI_FUNC define that does not come from this file and SWIG does not know anything about it.

Add

#define _VI_FUNC

like this:

%module IviDCPwr
#define _VI_FUNC
%{
#include <stdarg.h>
#include <limits.h>
#include <sys.types.h>
#include "visatype.h"
#include "visa.h"
#include "ivi.h"
#include "IviVisaType.h"
#include "IviDCPwr.h"
#include "IviDCPwrObsolete.h"
%}
%include "IviDCPwr.h"