LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

/Ze external compiler flag

Bonjour,

One quick question about enabling variable initialisation in for loop definition

 

I can compile an run the code below in CVI in debug mode 

 

#include <cvirte.h>#include <stdio.h>int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ for (int i=0; i<3; i++){ printf("Hello Dude\n"); } printf("Press ENTER to exit:"); getchar(); return 0;}

 

Now I use MSVC 2009 Express edition as an external compiler when I want to compile the Release version

When I try to compile then I got warnings and errors because of the declaration of the variable "i" in the for loop

I though the Microsoft extensions were enabled by default. 

Anyway... I went thru the options of the external compiler support

I tried to include the /Ze flag as an additional flag in the External Compiler Setup Dialog box

No way...even with the /Ze flag

When compiling the release version of the code with MSVC 2009, it seems the the declaration of "i" as an int is still a problem

 

Is there sometinig I missed?

Any idea ?

Regards, Philippe 

 

Regards, Philippe proud to be using LabWindows since version 1.2
// --------------------------------------------------------------------------------------------
0 Kudos
Message 1 of 4
(3,943 Views)

You've just discovered that Microsoft doesn't support C99 language features in the Visual Studio C++ compiler.

 

The native CVI compiler in release mode does support in-block variable declarations, as does the Intel C++ compiler for windows when you use it as the release compiler.

 

It appears also that Microsoft has no intention of ever making the VC++ compiler support the C99 extensions.

 

Menchar

0 Kudos
Message 2 of 4
(3,929 Views)

Have you tried it with the /TP flag? I don't know if this is supported by the Express version, but it should force C++ compilation rules, including making your declaration legal.

 

JR

0 Kudos
Message 3 of 4
(3,911 Views)

That'll work so long as he writes "clean C" that's in the common subset of C89 (plus the C99 features that NI has added) and C++.

 

This essentially means to always use function prototypes and not use C++ keywords such as "class" and "virtual".   There are several other areas where conflicts could arise though maybe rarely.  See H&S 1.1.5.

 

Menchar

0 Kudos
Message 4 of 4
(3,897 Views)