Thread: function compiled with g++
Why the same function writen in C, compiled with gcc works OK, but compiled with g++, doesn't even load? Not mentioning those written in C++. i.e. loader reports undefined symbol: pg_detoast_datum__FP7varlena or some other undefined symbol... I would actually need to know should I forget C++ for writing functions or am I just doing something wrong ? Thanks. Boris
> Why the same function writen in C, compiled with gcc works OK, but compiled > with g++, doesn't even load? Not mentioning those written in C++. > i.e. loader reports undefined symbol: pg_detoast_datum__FP7varlena or some > other undefined symbol... C++ compilers do "name mangling" to allow function overloading. If you are going to call a C++ routine from C or most other languages, you need to wrap the declaration for the called function in the following: extern "C" { retval your_function_here(arg1,arg2); } hth - Thomas
C++ mangles the symbols for linking, i.e. a function named "foo" might not be the symbol "foo". Try using the 'extern "C" { ... }' to make the symbols keep their names like in C. Hope this helps, Jeff Davis On Sunday 23 September 2001 11:03 pm, you wrote: > Why the same function writen in C, compiled with gcc works OK, but compiled > with g++, doesn't even load? Not mentioning those written in C++. > > i.e. loader reports undefined symbol: pg_detoast_datum__FP7varlena or some > other undefined symbol... > > I would actually need to know should I forget C++ for writing functions or > am I just doing something wrong ? > > Thanks. > Boris > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org