I was combining C and C++ codes for a certain application when I came across a peculiar feature. When I return a 'double' from cpp function called inside a c function the double values are not held. Here is a simple example:
File plus.cpp (cpp code)
extern "C" double f();
file main.c (c code)
w = f();
gcc -c main.c
g++ -c plus.cpp
g++ -o test *.o
The double value does not translate to the c code. Any ideas?
Thanks in advance
(PS: Things I cannot do -
1. Compiling C code using C++ compiler. The actual problem is a complex set of functions and libraries and this is not do able.
2. Convert C code to C++ or vice-versa. Same reason as above.
I am just trying to understand how the compilers work and/or reasons this happens.