Xcode 7.3: "Ambiguous Macro Extension" when overriding a macro in a prefix file

I am using Xcode 7.3 and I get a "Ambiguous Macro Extension" warning for a macro that was defined in Foundation, but which I have undefined and overridden in my prefix file. I have modules.

Playback:

  • Set "Enable Modules (C and Objective-C)" to "Yes" in the build settings
  • Use the following prefix file:

    #import <Foundation/Foundation.h> #undef assert #define assert(e) NSLog(@"hi") // implementation is not important 
  • Use the following main file:

     int main() { assert(42); return 0; } 
  • Then create in Xcode.

  • This shows the "Ambiguous extension of the macro warning" assert "in the line of the source file using the macro" assert. " The extension of this definition of "assert" refers to a definition from the system header, not my override. "Another definition of" assert "refers to a definition in my prefix file.

This warning does not occur when modules are disabled.

+8
macros ios compiler-warnings xcode clang
source share
1 answer

This is a bug in Xcode; we would be grateful if you could send a bug report to https://bugreport.apple.com and leave the # error here in the comment. Your options for working around this error now are:

  • You can use a different name than "assert" for this macro.
  • You can set the assembly parameter GCC_PRECOMPILE_PREFIX_HEADER to NO, since PCH does not have many advantages if you already have modules. The prefix header will still work, it just won't turn into PCH.
  • You can disable the modules.
+4
source share

All Articles