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)
PHP Code:
#include <stdio.h>
extern "C" double f();
double f()
{
   
double val=2.134;
   
printf("%lf\n",val);
  return 
val;

file main.c (c code)
PHP Code:
#include <stdio.h>
int main()
{
  
double w;
  
f();
  
printf("%lf\n",w);
  return 
0;

Compiling :
PHP Code:
gcc -c main.c
g
++ -c plus.cpp
g
++ -o test *.
Result:
PHP Code:
2.134000
-1752346657.000000 
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.
)