11-17-2008 11:03 AM
Hello,
I have a DLL that I want to use in a program developped by CVI (FDS version 8.5.1). The DLL comes with some documentation including an include file (*.h), where all the function declarations are given. So usually I would simply include this header file, unfortunately this file was written for C++ and contains function declarations of the following type:
typedef void (__stdcal *fp SOMETYPE) (double &, double &, long &, long ) .
Me and the compiler are confused by the '&', I know 'double' and 'double *', but not 'double &'... The same for CVI which complains with a syntax error, found '&' expecting ')'.
So obviously I have to manually translate this C++ header file into C style - but I have no idea how to do this... May be somebody could assist me? Thanks!
Solved! Go to Solution.
11-17-2008 12:36 PM
It's been a while since I've done any C++, but AFAIK, you can re-declare the function as:
typedef void (__stdcal *fp SOMETYPE) (double *, double *, long *, long )
in the header, and call it from your code by passing pointers or "address of" variables.
In this case the '&' in the function declaration means "by-reference". It's kind of like pointers in C, but allows for more error checking (eg - can't be NULL, can't be re-assinged, etc), and probably aids the compiler in optimizations. If you're interested, search google for C++ references, or you can check out wikipedia:
11-19-2008 07:48 AM
Thank you, this indeed solved my problem.
To summarize it for some future reference:
1) in the function declaration, replace the '&' with an '*':
typedef void (__stdcal *fp SOMETYPE) (double &) should be changed to typedef void (__stdcal *fp SOMETYPE) (double *)
2) in the function call, then use the address, '&': DLLfunctioncall (&value)
Wolfgang