extern seems to solve this problem
//main.c
-sharpinclude <stdio.h>
-sharpinclude "ggg.h"
int main(int argc, const char * argv[]) {
ggg();
return 0;
}
//ggg.h
-sharpifndef ggg_h
-sharpdefine ggg_h
-sharpinclude <stdio.h>
int num;//
void ggg();
-sharpendif /* ggg_h */
// ggg.c
-sharpinclude "ggg.h"
void ggg(){
num =1;
printf("ggg::%d",num);
}
//
duplicate symbol _num in:
/Users/HOHD/Library/Developer/Xcode/DerivedData/testGlobal-dorberrgmwayrsfxpllsxbyhhbud/Build/Intermediates.noindex/testGlobal.build/Debug/testGlobal.build/Objects-normal/x86_64/main.o
/Users/HOHD/Library/Developer/Xcode/DerivedData/testGlobal-dorberrgmwayrsfxpllsxbyhhbud/Build/Intermediates.noindex/testGlobal.build/Debug/testGlobal.build/Objects-normal/x86_64/ggg.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)