I have a multi-platform project, running on Windows, Linux and iOS right now, but I have stumbled upon a undesirable problem with Objective-C.
I have, unfortunately, chose the name exp for one of my types (expressions, pretty reasonable given the number of occurrences in my code), but Objective-C somehow includes the math.h header by default, creating a name-clash.
I tried to comment out everything in the .pch (the prefix file included by default before every source file), and exp is still flagged as redefinition.
Does anybody know how to not include math.h in a source file inside Objective-C project?
Objective-C does not have a formal specification, but it inherits features from C. In C, programs should not use identifiers from the standard headers, even if they do not include those headers. So, you should not use “exp” for your own identifiers.
If you insist upon using “exp”, you might be able to work around the issue with a preprocessor statement:
This will allow you to write “exp” in your source code as if it were one of your identifiers. Since the preprocessor will change it to “MyExp”, the compiler will see “MyExp” as the identifier and will not complain.
This will cause a number of problems, such as the identifier showing up as “MyExp” in object code information and in debugging tools and causing inability to use exp from math.h in the future.