LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Porting to VS7.net caused errors in <typedef>

I needed to port my software from CVI to VS7.net because CVI does not allow C++ classes.

In doing so, I encountered a problem from a vendor driver that had the following syntax:
typedef ViStatus _CVI_FUNC (*NEWTYPE)(ViPSession s);

It compiled fine under CVI, but it would not compile under VS7.net.
c:\Test\Utility.c(100) : error C2059: syntax error : '('

I looked at the values and here it was
ViStatus = ViInt32
_VI_FUNC = __stdcall
ViPSession = int *

After spending a lot of time time asking around what can cause this, I was told that this syntax could be fixed by moving the parenthesis.
typedef ViStatus (_CVI_FUNC *NEWTYPE)(ViPSession s);

We had to change our copy of the to
make our VS7.net project to work.

Why was this error found in VS7.net and CVI said it was okay?
- is this a new ANSI-C change?
0 Kudos
Message 1 of 2
(2,636 Views)
Hello

is _CVI_FUNC typedef'ed as _VI_FUNC ? I think what VC might have been doing is typedef'fing _CVI_FUNC as ViStatus, since it might not has a typedef for it. Im not sure about the vendor file, but if the vendor was trying to use standard visa types _CVI_FUNC doesnt seem to be one of them
Here are some of the CVI function prtotypes


#define CVICDECL __cdecl

/* CVICALLBACK is used for typdefs for ptrs to functions. For example:
* typedef void (CVICALLBACK * MenuDimmerCallbackPtr)(int menuBar, int panel);
*/
#define CVICALLBACK CVICDECL

/* for function prototypes */
#define CVIFUNC __stdcall
#define CVIFUNC_C CVICDECL
#define CVIANSI CVICDECL


and you have _VI_FUNC shown correctl
y. So you might be able to get the project to work as is if you add

#define _CVI_FUNC __stdcall

before the function declaration or perhaps in the project preprocessor definition.

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(2,636 Views)