How do you perform pass by variable on an interface function provided by a C library?
For example, I have the following interface function:
void f( double *d ) { *d = 7.5; }
In my application, I link through that library and call the function:
double p = 0;
f( &p );
However, I noticed p is still 0 and not 7.5.
Do you have the prototype for
fin scope, in your application?If you haven’t the compiler converts the address of
pto an int; and if they aren’t the same size or use the same passing conventions or whatever, you have problems.You should
#include "the_proper_header.h"or you may directly add the prototype in your application, right before you call the function.