#777 Swig ca't determine architecture correctly

closed-invalid
1
2009-11-14
2006-11-28
Adam Tkac
No

64bit machines swig can't include correctly files. I've created patch for this problem

---Steps to Reproduce---
> cat > test.i
%module test
# Make __NR_syscall names available
%include <sys/syscall.h>

> swig -python -I/usr/include -includeall test.i
/usr/include/asm/unistd.h:9: Warning(204): CPP #warning, This machine appears to
be neither x86_64 nor i386.
>

Discussion

  • Adam Tkac

    Adam Tkac - 2006-11-28

    simple patch for this problem

     
    Attachments
  • David M. Beazley

    Logged In: YES
    user_id=7557
    Originator: NO

    Won't fix. SWIG is not a low-level compiler. Moreover, the machine on which SWIG is run is often not the same on which wrapper code is compiled. If you need to do this, use the -D option.

    swig -python -D__i386__ whatever.i

     
  • David M. Beazley

    • priority: 5 --> 1
    • assigned_to: nobody --> beazley
    • status: open --> closed-rejected
     
  • Adam Tkac

    Adam Tkac - 2008-07-28

    Logged In: YES
    user_id=1655665
    Originator: YES

    I have to reopen this bug because problem is far more generic.

    When you wrapping something around C source and that source includes some standard header (stdio.h, stdlib.h and others) you have to have macros from C preprocessor. If you don't have it you can use incorrect structures/functions etc. It causes real problems - look into headers, everything is #ifdef-ined

    One possible solution will be define platform-specific macros directly in swig - this solution was rejected. Other solution will be get macros directly from C preprocessor - at least with GNU C preprocessor you can execute cpp -dM /dev/null and you can use output in swig.

    What is your status? I will write proposed patch (get macros from cpp on systems which has GNU cpp) if you are interested. If not, would it be possible propose another solution for this problem, please?

    Regards, Adam

     
  • Adam Tkac

    Adam Tkac - 2008-07-28
    • status: closed-rejected --> open
     
  • William Fulton

    William Fulton - 2008-07-31

    Logged In: YES
    user_id=242951
    Originator: NO

    The recommended approach is to write an interface file that has the needed methods from the C headers. SWIG provides platform neutral interface files for the C++ STL and you could model your approach on this. If you really want to %include a C library header and you want it to work in a platform specific way (not recommended), then create the macros. Use the info you provided:

    cpp -dM /dev/null > cppmacros.i

    then add a

    %include "cppmacros.i"

    into your interface file.

     
  • William Fulton

    William Fulton - 2009-11-14
    • status: open --> closed-invalid
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks