This question is related to this: "bad codegen, pointer diff" linker error with Xcode 4 and "bad codegen, pointer diff in boost" error in 32-bit build and XCode 3.2.6 and 4 linker errors ld:bad codegen, pointer diff in ... to global weak symbol
I am currently upgrading all my projects to Xcode4 and I am experiencing some weirdness.- The above error only occurs if I build a universal binary or the 32-bit version. If I stick to 64 bit only, things work fine. I am building a custom static library myself, where right now I don't use any visibility settings (i.e. attribute ((visibility ("default")))) in that code. If I link that library and try to build the project, the exact error is:
ld: bad codegen, pointer diff in Motor::Core::DefaultStoragePolicy::DefaultStoragePolicy(myWindowContent* const&)to global weak symbol Motor::Core::NullPointerException::~NullPointerException()for architecture i386
It is located in my SmartPtr class which can throw a NullPointerException (just derives from std::exception). If I explicitly set the visibility of the NullPointerException class to hidden, things compile fine, but hiding an exception can't be good! I tried the following compilers: GCC 4.2, LLVM-GCC 4.2 and LLVM 2.1 all with the same problem. Setting Symbols Hidden By Default to yes in he project/target settings didn't work (and is also not what I want). So how can I solve this without hiding my exceptions (which is nonsense). Do I have to live with it, is it a bug? Looking forward to you ideas, thanks!