Re: Duplicate symbol puzzle
Re: Duplicate symbol puzzle
- Subject: Re: Duplicate symbol puzzle
- From: Jens Alfke <email@hidden>
- Date: Thu, 20 May 2010 09:38:18 -0700
On May 20, 2010, at 8:22 AM, McLaughlin, Michael P. wrote:
> const flagType LOGFILE = 0x00000001ULL;
>
> The "duplication" was between two .m files both of which #imported Flags.h
> which, in fact, is included in most of my source files.
C doesn’t implement ‘const’ very well.
In C++ the above declaration would just define a compile-time constant similar to an enum value. But in C the semantics are just like declaring a regular global variable, except that it’s illegal to change its value. And since you put this in a header, you get the same duplication problem you get if you declare any global in a header without using ‘extern’.
The best way to fix it is to use an enum:
enum {
LOGFILE = 0x00000001ULL;
}
Or you can use Objective-C++ by changing your source files’ extensions to “.mm”.
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden