B
Bharath
Hi All,
I am a newbie to C++ and I'm trying to figure this out. Can you please
help?
We have 3rd party library that's written in c++. We don't have the
source for it. ldd on that shared library indicates that it depends on
libstdc++. It has a printf() like function called
void xxx_print (char *format, ...)
The executable I built has to source files file_1.cpp and file_2.cpp.
In file_1.cpp, I had this line.
extern void xxx_print (char *format, ...);
In file_2.cpp, I had this line (accidentally)
extern "C" void xxx_print (char *format, ...);
When I ran the executable, the moment xxx_print statement was executed
in any function in file_2.cpp, the process died with exit code 127.
gdb didn't catch anything -- said it's because of GDB's internal
error.
I took off extern "C" (actually, included the header file) and all is
well now. I know that extern "C" is for linking against C code to take
care of name-mangling issues but in this case I had no issues building
and everything is fine as long as no xxx_print is done in file_2.cpp.
All xxx_print statements in file_1.cpp work fine.
I don't know what is messed up. Eventhough the problem is solved I
wanted to understand this better. Your help is greatly appreciated.
Thanks,
B
I am a newbie to C++ and I'm trying to figure this out. Can you please
help?
We have 3rd party library that's written in c++. We don't have the
source for it. ldd on that shared library indicates that it depends on
libstdc++. It has a printf() like function called
void xxx_print (char *format, ...)
The executable I built has to source files file_1.cpp and file_2.cpp.
In file_1.cpp, I had this line.
extern void xxx_print (char *format, ...);
In file_2.cpp, I had this line (accidentally)
extern "C" void xxx_print (char *format, ...);
When I ran the executable, the moment xxx_print statement was executed
in any function in file_2.cpp, the process died with exit code 127.
gdb didn't catch anything -- said it's because of GDB's internal
error.
I took off extern "C" (actually, included the header file) and all is
well now. I know that extern "C" is for linking against C code to take
care of name-mangling issues but in this case I had no issues building
and everything is fine as long as no xxx_print is done in file_2.cpp.
All xxx_print statements in file_1.cpp work fine.
I don't know what is messed up. Eventhough the problem is solved I
wanted to understand this better. Your help is greatly appreciated.
Thanks,
B