"Bonj" <benjtaylor at hotpop d0t com> wrote...
I can use
extern "C" ...
to link a C variable or runction into a C++ file, but what if I want to
link a C++ variable into a C file? I get errors trying to use extern "C++"
and it seems like it is looking for a variable with an additional
underscore at the beginning, is the linker.
Any ideas?
You cannot link a file compiled with a C++ compiler to another compiled
with a C compiler, using a C linker. That's likely not going to work.
What you need is
(a) Declare the symbol in the C++ file as 'extern "C"' when compiling
(b) Link both together using a C++ linker
The reason is simple: the C language is older and when the object code
and linking specifications were developed, there was no C++, so most of
the C compilers/linkers still follow those quarter-a-century old guide-
lines. Besides, there is a bit of that "I've been here before you, I
am better than you, and I am not going to give you the second thought"
attitude coming from the C camp. No big deal, C++ programmers just work
around all that.
V