Precompiled header problem
Precompiled header problem
- Subject: Precompiled header problem
- From: "Jeff Schmidt" <email@hidden>
- Date: Tue, 25 Apr 2006 10:52:48 -0500
A variant of this question has been previously asked by a coworker on
this list without a real solution. I'm going to try rephrasing it and
see if any Xcode/gcc experts here might have some additional insight.
I have a large C++ project with a precompiled header. The entire
project, but not some sublibraries, specify C++ compilation for all
files (so only one PCH haunting me). This is using gcc 4.0 building
for i386, but it also happens building for PPC. On link, a selection
of constants in the precompiled header turn up undefined, and the
linker says they are referenced by the precompiled header. The
constants are in a namespace, contained in one header included as
part of the precompiled header, and other constants within that same
file are apparently OK. Another clue, it centers around two constants
who are then used in a series of other constant definitions. They all
end up undefined.
Header snippet:
namespace PortLib {
#if TARGET_MACOS || TARGET_WIN32
const LONG kMaxDocsOpen = LONG_MAX;
#else
#include <climits>
const LONG kMaxDocsOpen = LONG_MAX;
#endif
// Resolution of document space at 100% scale
const HIFLOAT kDocSpaceDPI = 72.0;
// Range for user scales
#if BIG_PAGE_MAX
const HIFLOAT kMinScale = 0.01;
#else
const HIFLOAT kMinScale = 0.25;
#endif
const HIFLOAT kMaxScale = 8.0;
const HIFLOAT kAlmostEqualDiff = 1.0 / (2.0 * kDocSpaceDPI * kMaxScale);
... dozens of additional declarations ...
}
Many more undefined constants follow (derived from either
kDocSpaceDPI or kMaxScale or both).
Build log error snippet for code above:
/Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/
CreatorServerDebug-avefshvwsedytaauvaarzdqqgjnv/
CreatorServerDebug.pch.gch.o reference to undefined
PortLib::kDocSpaceDPI
/Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/
CreatorServerDebug-avefshvwsedytaauvaarzdqqgjnv/
CreatorServerDebug.pch.gch.o reference to undefined
PortLib::kAlmostEqualDiff
/Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/
CreatorServerDebug-avefshvwsedytaauvaarzdqqgjnv/
CreatorServerDebug.pch.gch.o reference to undefined PortLib::kMaxScale
... a dozen or so more undefined references in the PCH ...
There are plenty of other constants in this namespace that survive
compilation and linking just fine, what possible reasons would there
be for only these to fail? Could these actually be referenced
someplace else and causing the link error, contrary to the error
message? It's hard for me to fathom why constants defined in a PCH
would then turn out undefined -- referenced from that very PCH -- at
link.
Any expert tips or insights to help resolve this problem are welcome.
_______________________________________________
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