I have a difference when compiling objective-c source and objective-c++ source.
Here a declaration of Class1 and Class2 in test.h :
#import <Foundation/Foundation.h>
@interface Class1 {
}
@end
@interface Class2 {
}
@end
Now, this is Objective-C implementtion in test.m :
#import "test.h"
@implementation Class1
/* static member */
static int mystatic;
@end
@implementation Class2
/* static member */
static int mystatic;
@end
I compile successfully with this command :
gcc -arch armv6 -isysroot /Developer/.../iPhoneOS5.0.sdk -x objective-c -c test.m
Now I use exactly the this Objective-C++ implementation test.mm (exactly same source) :
#import "test.h"
@implementation Class1
/* static member */
static int mystatic;
@end
@implementation Class2
/* static member */
static int mystatic;
@end
And compile with this command line (difference in -x option) :
gcc -arch armv6 -isysroot /Developer/.../iPhoneOS5.0.sdk -x objective-c++ -c test.mm
But I get an error :
test.mm:11 error: redefinition if 'int mystatic'
Why I get this error in ObjC++ and not in ObjC ?
static
is file scoped, not class scoped) but why the Objective-C compile doesn't catch is beyond me... – Backhander