> I can use
> extern "C" ...
[quoted text clipped - 4 lines]
> Any ideas?
> Cheers
I don't think the "C" compiler supports anything but extern, so your only
option is to extern "C" your C++ variable. The SDK headers conditionally
#define EXTERN_C, so you can...
// SomeCommon.h
EXTERN_C INT g_nValue;
// SomeCpp.cpp
#include "Some.h"
EXTERN_C INT g_nValue = 0;
// SomeC.c
#include "Some.h"
VOID _cdecl SomeFunc(VOID)
{
INT n = g_nValue;
}

Signature
Jeff Partch [VC++ MVP]
"Bonj" <benjtaylor at hotpop d0t com> wrote...
>I can use
> extern "C" ...
[quoted text clipped - 3 lines]
> 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
Bonj - 16 Oct 2004 23:26 GMT
> 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.
Well that's a shame that they do, but at the end of the day you know that
ultimately he who knows when to use a C file and when to use a C++ file will
build the best program.
> V
Bonj - 17 Oct 2004 13:52 GMT
You shouldn't see C programmers as rivals, if they've got a bee in their
bonnet then it's probably only because they don't even know how to use C++
they've been using C for so long. Although I think there's a rapidly
declining number of people to who this can be attributed.
At the end of the day, the two should compliment each other.
>> 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"
[quoted text clipped - 6 lines]
>
>> V