bg***@yahoo.com wrote:
To start with, I had 3 c files which I linked using bcc32 -
bcc32 1.c 2.c 3.c
Now I need to convert 1.c to 1.cpp. 1.cpp contains the main function.
The problem is that I now get "Undefined symbol" for any fuction
found in 2.c or 3.c that I try to call from 1.cpp.
I'm guessing the problem is to do with name mangling, but what should
I do exactly to resolve this problem?
What usually happens is that you change one file to compile with a C++
compiler, but forget to change the declaration of the functions from the
other (C) files to contain 'extern "C"'. The compiler thinks the have
C++ linkage and they don't.
There are two solutions: either change the declarations in the header
files to contain 'extern "C"' _if_ you compile with a C++ compiler:
---- some header included in both C and C++ sources:
#ifdef __cplusplus
extern "C" {
#endif
int foo(void);
void bar(int);
#ifdef __cplusplus
}
#endif
------------------------------
*or* compile _all_ files now using a C++ compiler.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask