Undefined constants from pch
Undefined constants from pch
- Subject: Undefined constants from pch
- From: Steve Mills <email@hidden>
- Date: Tue, 18 Apr 2006 14:43:26 -0500
I've asked about this before, but never got a good answer that I can
find. We have a header that has a bunch of constants defined using
the "const type name = value;" construct. All of the constants are
inside a namespace block. This file is included from our prefix
header. When I first began converting our projects from CW to Xcode,
I got compiler errors when the C precompiler ran into C++isms in
the .h file (namely, "namespace"). I fixed that by NOT including that
file from the .pch if __cplusplus was defined. So when Xcode
precompiled the C pch, it worked, and when it precompiled the C++
pch, it also worked.
Some time later I converted another project that also uses the .h
file with the constants in it. The pch was set up the same way to NOT
include it when __cplusplus was defined. However, this project
produced link errors saying that all of the constants in the .h file
were undefined symbols (it mentioned their mangled names). Since this
project doesn't have any .c files, I was able to get around the link
errors by only precompiling for c++ and compiling source files as C+
+. This is something I did *not* do for the first project, because it
contains .c files.
Recently another engineer was working on a 3rd project and ran into
the same thing. This project contains many of the same files as the
first project does (our portable code). This project produces the
link errors. We've both been screwing with the project for many days
and have come up with nothing.
So, Apple Xcode engineers, what would cause a constant to be
undefined in one project but not the other? The 3rd project's link
errors says the symbols are referenced from the .pch.gch.o file.
Nothing directly or indirectly in the .pch makes reference to those
constants outside of the .h file in which they are defined.
Steve Mills
Drummer, Mac geek
http://sjmills5.home.mchsi.com/
_______________________________________________
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