Menu

Home

William Fulton

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of target languages including common scripting languages such as Perl, PHP, Python, Tcl and Ruby. The list of supported languages also includes non-scripting languages such as C#, Common Lisp (CLISP, Allegro CL, CFFI, UFFI), D, Go language, Java, Lua, Modula-3, OCAML, Octave and R. Also several interpreted and compiled Scheme implementations (Guile, MzScheme/Racket, Chicken) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG is typically used to parse C/C++ interfaces and generate the 'glue code' required for the above target languages to call into the C/C++ code. SWIG can also export its parse tree in the form of XML and Lisp s-expressions.


Project Admins:


Discussion

  • zhuzhenping

    zhuzhenping - 2017-05-21

    swig is good, when use "julia" language ?

     

    Last edit: zhuzhenping 2017-05-21
  • prabhat Ghosh

    prabhat Ghosh - 2017-07-07

    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>
    %feature("director");
    %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.

     

Log in to post a comment.