SWIG is throwing error while compiling C/C++ Code

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

SWIG is throwing error while compiling C/C++ Code

Prabhat Ghosh


I have a old C\C++ unmanaged dll. we need to call it from C#. So, trying to generate files through SWIG so the I can call it from C# project -

we have 7 headers, 9 .CPP files in c++ Code Base and it is in module structure, functions are directly written in the .CPP files no class is present , they are like -

RESOURCE.H - Version Info for the DLL
XTYPE.H - This file contains all type definitions including structs used in the X dll
XMSG.H - This file contains the message constants
XCONS.H - This file contains all constant definitions used in the X project
CX.H - This file contains the function declarations for all functions using C structures which are exported from X.DLL
SX.H - This file contains the function declarations for all functions exported from X.DLL for use with SQLWindows applications.These functions use a list of variables as arguments.
XGLOB.H - This file contains the global variable declarations used by X. Also all the function signature present in all the respective header/source file.

I am using below .i file -

%module(directors="1") X

#include "RESOURCE.H"
#include "XTYPE.H"
#include "XMSG.H"
#include "XCONS.H"
#include "CX.H"
#include "SX.H"
#include "XGLOB.H" 

%include <windows.i>
%include "RESOURCE.H"
%include "XYPE.H"
%include "XMSG.H"
%include "XCONS.H"
%include "CX.H" -> this header includes SX.H,XGLOB.H
%include "SX.H" -> this header includes XYPE.H
%include "XGLOB.H" -> this header includes RESOURCE.H,XTYPE.H,XMSG.H,XCONS.H

there are functions where I am facing error while compiling the .i file through SWIG to generate files using Visual Studio 2015 -

few of them are like -

LONG CALLBACK XWndProc(HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam); - throwing "Syntax error - possibly a missing semicolon." error
BOOLEAN __declspec(dllexport) WINAPI XGetCardPosition(GETCARDPOSITIONPARAM FAR * CardCoordinates); - throwing "Syntax error in input(1)." error

Please let me know, what should be my .i file so that these errors could be removed and can proceed with generating correct files to call from C# project.


Prabhat Ghosh.

Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Swig-user mailing list
[hidden email]