Re: Proper use of Header files
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