This is different from the usual confusion over duplicate symbolic errors ... :-)
I am working on some legacy Mac code in an Xcode project that has the same global “trace” defined in several different source files, for example:
- File1.c: SInt32 trace
- File2.c: Boolean trace;
etc. .. It is clear that the original author meant that they have a file-specific area, but simply ignored the prefix of any of these lines with "statics". This is fine, easy to fix.
But I’m shocked that the linker will not interfere with this! It seems to me that the Xcode linker (I believe gnu ld) emits only duplicate warnings or errors for functions that are associated with a code segment, but not global variables that are associated with a data segment. Instead, it quietly merges them, which causes errors.
So ... how do I convince Xcode to emit link errors for duplicate global variables? Or get this information in some other way that might be a regular part of my build?
linker xcode ld macos
Bob murphy
source share