#1001 Mac OS X: check already defined as macro

closed-invalid
ruby (61)
5
2010-09-27
2009-03-13
Blakharaz
No

In Mac OS X the header file AssertMacros.h already defines check as a assertion macro. This leads to compiler errors for some generated code creating or using check identifiers:

E.g.:

template <class Type>
struct traits_check<Type, value_category> {
static bool check(VALUE obj) {
int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR;
return SWIG_IsOK(res) ? true : false;
}
};

template <class Type>
struct traits_check<Type, pointer_category> {
static bool check(VALUE obj) {
int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR;
return SWIG_IsOK(res) ? true : false;
}
};

template <class Type>
inline bool check(VALUE obj) {
return traits_check<Type, typename traits<Type>::category>::check(obj);
}

Discussion

  • William Fulton

    William Fulton - 2009-03-13

    Does a
    #undef check
    in rubyhead.swg fix it for you?

     
  • William Fulton

    William Fulton - 2009-03-14

    You're going to have to supply a standalone interface file in order for us to replicate the problem and fix this as you are referring to files that don't exist in SWIG and we don't have time to guess your setup.

     
  • Blakharaz

    Blakharaz - 2009-03-15

    Input file for reproducing the problem

     
  • Blakharaz

    Blakharaz - 2009-03-15

    File Added: check-test.i

     
  • Blakharaz

    Blakharaz - 2009-03-15

    check-test.i seems to be the shortest input file showing the problem.

    The commands for testing I used are:

    swig -ruby -c++ check-test.i
    gcc -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/Headers check-test_wrap.cxx

    For me it shows 5 compiler errors. If the bug is fixed there should be just linker errors.

     
  • William Fulton

    William Fulton - 2009-03-17

    SWIG is generating perfectly valid code, the traits_check::check method is in a unique namespace (Swig) and the check symbol is a standard conforming symbol and will coexist with other standard conforming code. The AssertMacros.h header is polluting the global namespace and SWIG does not use it. It is you who has chosen to use this header and so you must fix up the problems associated with it. It is easy, just put a

    #undef check

    after the #include "AssertMacros.h".

    or ask Apple to fix up the pollution in this header.

     
  • William Fulton

    William Fulton - 2009-03-17
    • assigned_to: gga73 --> wsfulton
    • status: open --> closed-invalid
     
  • Blakharaz

    Blakharaz - 2009-03-17

    Sorry, I didn't point that out: I did _not_ add the AssertMacros.h header intentionally (this is just for the example code).
    In our code I just added the <Carbon.h> umbrella header or it is another header which includes the AssertMacros.h.
    I agree that apple is polluting the global namespace with that check macro. Maybe a hint in some FAQ documents is enough for that issue because the compiler error is really strange.

     
  • Blakharaz

    Blakharaz - 2009-03-17
    • status: closed-invalid --> open-invalid
     
  • Olly Betts

    Olly Betts - 2010-09-27
    • status: open-invalid --> closed-invalid
     
  • Olly Betts

    Olly Betts - 2010-09-27

    Already marked invalid, actually closing.

     
  • Olly Betts

    Olly Betts - 2010-09-27

    Already marked invalid, actually closing.

     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks