• 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: Weird error situation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird error situation


  • Subject: Re: Weird error situation
  • From: Chris Espinosa <email@hidden>
  • Date: Sun, 23 Sep 2007 22:10:06 -0700


On Sep 23, 2007, at 9:57 PM, Adam wrote:

...but I have #pragma once at the top! Doesn't that pretty much fix the problem? I used Cris Suter's advice and slapped an "extern" on the ones that it said were having a problem, and bingo! it's fixed. The only thing now is that it's giving me warnings about some bool functions that I have:

No, that just means it only gets processed once per compilation unit.  Not once per build.  Every C++ file you compile has to read the header file at least (and preferably only) once, but each gets a definition of the global, then when you link all the compilation units together, you've defined each global three times.

Look, it's simple:

- declare as extern in a .h protected by a header guard or #pragma once
- define in a .cp file that you build exactly once per linked executable
- #include the .h file from the source file that defines it, as well as every other source file that uses it

This is elementary C.  

Chris
 _______________________________________________
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

References: 
 >Weird error situation (From: Adam <email@hidden>)
 >Re: Weird error situation (From: Chris Espinosa <email@hidden>)
 >Re: Weird error situation (From: Adam <email@hidden>)
 >Re: Weird error situation (From: Chris Espinosa <email@hidden>)
 >Re: Weird error situation (From: Adam <email@hidden>)
 >Re: Weird error situation (From: Chris Espinosa <email@hidden>)
 >Re: Weird error situation (From: Adam <email@hidden>)
 >Re: Weird error situation (From: Chris Espinosa <email@hidden>)
 >Re: Weird error situation (From: Adam <email@hidden>)

  • Prev by Date: C++ Constructors on global vars not being run ?
  • Next by Date: Re: C++ Constructors on global vars not being run ?
  • Previous by thread: Re: Weird error situation
  • Next by thread: Re: Weird error situation
  • Index(es):
    • Date
    • Thread