Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Precompiled header problem



On Apr 25, 2006, at 12:17 PM, Chris Espinosa wrote:
Well, there's a very simple explanation. const definitions are code, and gcc stops precompiling headers when it reaches the first line of code.

Precompiled headers are applied as a prefix to every source file in your target. So if gcc emitted code for these const definitions in the pch, you'd have multiple definitions of the constants, one for every source file. The linker wouldn't like that.

You have two choices:

1) Use macros instead of const declarations.
2) Declare the consts as "extern" in your precompiled header, and do the formal definitions in a single source file in your build (not in a header file or the prefix file).

So why would this header work when included in a PCH for some projects, but not this one? If I'm understanding your description of gcc precompilation, I'd expect it to fail wherever it's used in that way. I don't find that to be the case.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden


This email sent to email@hidden
References: 
 >Precompiled header problem (From: "Jeff Schmidt" <email@hidden>)
 >Re: Precompiled header problem (From: Chris Espinosa <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.