• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Duplicate symbol puzzle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Duplicate symbol puzzle
      • From: "Sean McBride" <email@hidden>
References: 
 >Duplicate symbol puzzle (From: "McLaughlin, Michael P." <email@hidden>)

  • Prev by Date: Duplicate symbol puzzle
  • Next by Date: Re: Duplicate symbol puzzle
  • Previous by thread: Duplicate symbol puzzle
  • Next by thread: Re: Duplicate symbol puzzle
  • Index(es):
    • Date
    • Thread