04-15-2009 12:05 PM
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
04-16-2009 02:48 AM
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.
04-16-2009 03:40 AM
04-16-2009 12:11 PM
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.
12-07-2015 05:36 AM
clang supports this directive, and thus the newer versions of CVI (2013 ff) also recognize it