Menu

#858 The TRUE/FALSE bug on MacOS X, revisited

2.0 Series
closed-fixed
General (291)
5
2009-01-15
2009-01-10
No

With the source in its current state, I get the following error when building makensis 2.42 on MacOS X Server 10.3.9:

g++ -o build/release/makensis/util.o -c -Wno-non-virtual-dtor -O2 -Wall -I. -Iexehead "-DNSISCALL= __attribute__((__stdcall__))" -D_WIN32_IE=0x0500 /tmp/nsis-2.42-src/Source/util.cpp
In file included from /tmp/nsis-2.42-src/Source/util.cpp:38:
/usr/include/mach-o/dyld.h:74: error: use of enum `DYLD_BOOL' without previous
declaration

Line 74 of /usr/include/mach-o/dyld.h is as follows:

extern enum DYLD_BOOL NSDestroyObjectFileImage( <---- line 74
NSObjectFileImage objectFileImage);

Now, I've reviewed bug #1851365. I suspect that the fix committed for that one didn't help here because this older header file is making use of "enum DYLD_BOOL" for the NSDestroyObjectFileImage() prototype, whereas later versions presumably have changed this to return a straight int. The old fix ("#define ENUM_DYLD_BOOL") inhibits the definition of the DYLD_BOOL enum, which causes the compiler to choke on the use of that enum in the prototype.

Here's the problematic bit, farther up in dyld.h:

#ifndef ENUM_DYLD_BOOL
#define ENUM_DYLD_BOOL
#undef FALSE
#undef TRUE
enum DYLD_BOOL {
FALSE,
TRUE
};
#endif /* ENUM_DYLD_BOOL */

Same as in the newer version. And here is the relevant snippet of Source/util.cpp, as currently in SVN:

#ifdef __APPLE__
namespace Apple { // defines struct section
# define ENUM_DYLD_BOOL // for TRUE/FALSE, bug #1851365
# include <mach-o/dyld.h> // for _NSGetExecutablePath
};
# include <sys/param.h> // for MAXPATHLEN
#endif

The following variation allows compilation to succeed:

#ifdef __APPLE__
namespace Apple { // defines struct section
# include <mach-o/dyld.h> // for _NSGetExecutablePath
};
# define FALSE 0
# define TRUE 1
# include <sys/param.h> // for MAXPATHLEN
#endif

Not a pretty solution, but Apple's idiotic use of "TRUE" and "FALSE" in a system header kind of forces the issue....

Discussion

  • Amir Szekely

    Amir Szekely - 2009-01-10
    • status: open --> pending
     
  • Amir Szekely

    Amir Szekely - 2009-01-10

    How would that get DYLD_BOOL properly declared? According to the quoted code, it won't be declared unless ENUM_DYLD_BOOL is defined.

     
  • Daniel Richard G.

    • status: pending --> open
     
  • Daniel Richard G.

    Er... you mean, DYLD_BOOL won't be declared unless ENUM_DYLD_BOOL is UNdefined. Both are defined together, and then the latter is used to prevent the former from being defined a second time.

     
  • Amir Szekely

    Amir Szekely - 2009-01-15

    Right, I see it now. Fixed for next version. Let me know if it still doesn't work.

     
  • Amir Szekely

    Amir Szekely - 2009-01-15
    • assigned_to: nobody --> kichik
    • status: open --> closed-fixed
     

Log in to post a comment.