Xcode 7.3: "Ambiguous expansion of macro" when re-defining macro in prefix file

Viewed 4567

I am using Xcode 7.3, and I am getting an "Ambiguous expansion of macro" warning, for a macro which was defined in Foundation, but which I have undefined and re-defined in my prefix file. I have modules enabled.

To reproduce:

  • Set "Enable Modules (C and Objective-C)" to Yes in 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 source file:

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

  • It shows an "Ambiguous expansion of macro 'assert'" warning on the line in the source file that uses the "assert" macro. The "Expanding this definition of 'assert'" points to the definition from the system header, not my redefinition. The "Other definition of 'assert'" points to the definition in my prefix file.

This warning does not happen when modules is disabled.

1 Answers
Related