Re: Help -- ESQL C problems
Posted in 1997
The problem is C++'s name mangling of function names. In C++, functions in different classes can have the same name (Draw() could be in both the Circle and the Square class). Since C++ first converts code into c code, functions with the same name need to be converted into unique names (like: draw_circle(), draw_square()), hence name mangling. Thus, instead of looking for dectodbl(), it's looking for something like dectodbl_xx(), or whatever. But the libraries were compiled in C, and contain the actual function names, so it can't resolve the function. To use code compiled in C, use the ' extern "C" ' keyword: extern "C" { #include <decimal.h> } This tells the comiler not to mangle the names in the header file; thus it will now look for dectodbl(), and find it in the library. Paul 131AC0000-BasuA(DR2783)231 <abasu@dr.lucent.com> wrote in article <33628218.7781@dr.lucent.com>... > > Here's a simle code segment I'm trying to compile: > > #include <decimal.h> > main() > { > double dbl_val; > dec_t dec_val; > int ret_val; > ret_val = dectodbl(&dec_val, &dbl_val); > } > > > dectodbl seems to be undefined when using a C++ compiler. Works fine > if I use the c compiler. Older versions of informix did not seem to > have this problem. It started with informix 7.22. > > exec /opt/SUNWspro4.1/bin/CC -I/opt/informix7.22/incl/esql main.c > -L/opt/informix7.22/lib -L/opt/informix7.22/lib/esql -lixsql -lixasf > -lixgen -lixos -lixgls -lnsl -lsocket -laio -lm > /opt/informix7.22/lib/esql/checkapi.o > Undefined first referenced > symbol in file > dectodbl(decimal*, double*) main.o > > > Any help in this matter will be greatly appreciated. > > Thanks > /anand >