LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Linking to C++ DLL

I am trying to link to a C++ DLL.   The DLL includes a lib and header file.
However, when I try to compile I get "Warning: Empty Declaration" error
 
#define dllexp __declspec( dllexport )
#define dllimp __declspec( dllimport ) 
extern "C" {
 
 //see descriptions and examples in call8v.cpp
 dllimp short DsoDetect(unsigned char* CfgBuffer);
 dllimp void ExitDSO(unsigned char* CfgBuffer);
 
Ive attached a screenshot of the project.
 
Thanks in advance.
Diego
 
0 Kudos
Message 1 of 3
(3,686 Views)
extern "C" is a C++ specific feature to compile/reference functions with C linkage from C++ code. It is meaningless (an an error) in C programs.

The normal way to work around this (as the extern "C" is absolutely necessary in C++ programs building or using the DLL) is to exclude instances of extern "C" except in C++, using the preprocessor.

You can see this for yourself if you look at the headers CVI installs; from userint.h:

#ifdef __cplusplus
    extern "C" {
#endif


and

#ifdef __cplusplus
    }
#endif

If you wrap this opening line and its closing brace in these guards, it should solve your problem.

Regards,

-alex
0 Kudos
Message 2 of 3
(3,674 Views)
Alex,
Thanks very much for your quick response.
Yes, U are correct and it did work.
 
Thanks
Diego
0 Kudos
Message 3 of 3
(3,640 Views)