Re: C with C++ in xcode
Re: C with C++ in xcode
- Subject: Re: C with C++ in xcode
- From: "E. Wing" <email@hidden>
- Date: Wed, 28 Sep 2005 11:32:35 -0700
> From: Joe Kurtz
> Thanks for the replies.
>
> I've tried both Eric's and Markian's suggestion. Nope.
> I get the same error reported by the linker (undefined
> symbols).
It's hard to say what's going on. One thing I think you do need to
make sure of is that you compile the C code as C and not C++. Is the C
code directly included in your project or are you linking against it?
I think if you use the first method (Eric Albert's) and put the guards
in all your C header files, then this will be probably be handled
automatically for you.
If you use the second method (or my variation of the second method),
you have to be more careful about how your C code gets compiled.
For example, if you have a main.cpp that uses a foo.h and foo.c, if
you put the __cplusplus guard in the main.cpp (the second method) and
not foo.h, then you have to make sure you compiled foo.c with the C
compiler (gcc) and not the C++ compiler (g++). In this case, this
command should fail to link:
g++ main.cpp foo.c
(If you use the first method, this should work.)
Conversely, if you leave out the header guards entirely and run this
command, everything should compile under C++ and I think it should
also work. But if you built foo using just the C compiler and main
with the C++ compiler, when you try to link them, they will fail.
If you are using the second method, and you think your C code might be
being compiled as C++, you might try building the C code into a
separate library first so there is no risk of contamination. Then you
just need to make sure you added all your cplusplus guards in your C++
code. If this continues to fail, it might mean you missed a guard, or
there is something else wrong that's unrelated to this, or I am
totally off the mark.
> Maybe there's something else amiss here.
> I note that the c functions I want to use are
> returning float** types.
> (could this have implications?)
As far as I know, this shouldn't be a problem.
_______________________________________________
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