LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Does CVI native compiler support pragma once?

The LCC-win32 compiler supports the pragma "once", I was wondering if it turns out that the CVI compiler recognizes it.

 

If it does, it saves doing all the work of guarding include files to prevent multiple inclusion and redefinition errors.

 

Menchar

0 Kudos
Message 1 of 5
(4,161 Views)

i just tested this, and CVI does not support  "#pragma once". the pragma is silently ignored, as all unknown pragma.

 

however, not all compilers support #pragma once, thus using #ifdef/#define is still the most portable way to guard header files against multiple inclusions.

 

anyway, it would be nice to have such a pragma, as well as #prama comment( lib, "..." ) (which i already filed as a feature request), and #pragma error or #pragma warning. i also would like CVI to output a warning when it encounters an unknown pragma, it would help to know what is supported. also the documentation page for pragma is incomplete: some supported pragma are missing, like the one to enable C99.

0 Kudos
Message 2 of 5
(4,142 Views)
> and #pragma error or #pragma warning.

There's already #error, and I'd like #warning which is supported in many
compilers and very useful to track down inclusion problems without stopping
the compilation as #error does in some cases.
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 3 of 5
(4,138 Views)

Thanks for the info.

 

I have been using #ifndef / #define  to guard header files then I started doing some C++ work and noticed this pragma.

 

 

0 Kudos
Message 4 of 5
(4,118 Views)

clang supports this directive, and thus the newer versions of CVI (2013 ff) also recognize it Smiley Happy

0 Kudos
Message 5 of 5
(3,375 Views)