• 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: Proper use of Header files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proper use of Header files


  • Subject: Re: Proper use of Header files
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 29 Oct 2012 09:59:22 -0700


On Oct 29, 2012, at 8:39 AM, Howard Moon <email@hidden> wrote:

If the header is read by more than one implementation file, the compiler will generate more than one copy of the code, probably causing problems with the linker.

There is no such problem.  Try it and see.  If you're getting multiply-defined symbols, then you've forgotten include guards (or #pragma once).

Huh? Of course this is a problem. I think you must have misread the description (it’s a _linker_ issue, not a compile-time issue.)

This has nothing to do with #include guards. If you have a global symbol defined (not just declared) in a header, then its definition will appear in the object code of every source file that includes that header. If there’s more than one such source file, the linker will complain that the symbol is multiply defined. 

—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

References: 
 >Proper use of Header files (From: koko <email@hidden>)
 >Re: Proper use of Header files (From: David Rowland <email@hidden>)
 >Re: Proper use of Header files (From: Howard Moon <email@hidden>)

  • Prev by Date: Re: Automatic provisioning profile selector
  • Next by Date: Re: How to make a path relative to the current Xcode application?
  • Previous by thread: Re: Proper use of Header files
  • Next by thread: How to use Instruments to profile network I/O?
  • Index(es):
    • Date
    • Thread