LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple include files

Hello:
 
Running into a lot of company written  #include files
where no protection is taken such as:
 
#ifndef __HEADERFILE_H
#define __HEADERFILE_H
 
blah, blah...
 
#endif
 
Files are included 2 and sometimes 3 times.
Strange part about this everything works properly.
 
Is CVI that smart that it figures out you only want one include?
0 Kudos
Message 1 of 2
(2,956 Views)
CVI does not do any work to guarantee than include files are only included once. There are even language reasons why we would not want to do this.
 
However, many redeclarations are legal and therefore many header files will probably compile fine even if included multiple times.
 
Struct declarations and enumerations will complain, but function prototypes and variable externs (for example) are ok.
 
Since many C API header files simply contain #defines and function prototypes, multiple inclusion will often still result in a successful (if slower) compile.
 
Hope this helps,
 
-alex
0 Kudos
Message 2 of 2
(2,944 Views)