I have a difference when compiling the source of objective-c and objective-c ++.
Here's the declaration of Class1 and Class2 in test.h:
Now this is the implementation of objective-c in test.m:
#import "test.h" @implementation Class1 /* static member */ static int mystatic; @end @implementation Class2 /* static member */ static int mystatic; @end
I will successfully compile this command:
gcc -arch armv6 -isysroot /Developer/.../iPhoneOS5.0.sdk -x objective-c -c test.m
Now I use this exact-c ++. Mm test (exactly the same source):
#import "test.h" @implementation Class1 /* static member */ static int mystatic; @end @implementation Class2 /* static member */ static int mystatic; @end
And compile this command line (the difference is in the -x option):
gcc -arch armv6 -isysroot /Developer/.../iPhoneOS5.0.sdk -x objective-c++ -c test.mm
But I get an error message:
test.mm:11 error: redefinition if 'int mystatic'
Why am I getting this error in ObjC ++ and not in ObjC?
source share