once

Controls whether or not a header file can be included more than once in the same compilation unit.

Syntax
#pragma once [ on ]
  
Remarks

Use this pragma to ensure that the compiler includes header files only once in a source file. This pragma is especially useful in precompiled header files.

There are two versions of this pragma:

#pragma once  

and

#pragma once on 

Use #pragma once in a header file to ensure that the header file is included only once in a source file. Use #pragma once on in a header file or source file to ensure that any file is included only once in a source file. When a once option or pragma is used, a header file of same name in another directory is not included.

Beware that when using #pragma once on , precompiled headers transferred from one host machine to another might not give the same results during compilation. This inconsistency is because the compiler stores the full paths of included files to distinguish between two distinct files that have identical file names but different paths. Use the warn_pch_portability pragma to issue a warning message when you use #pragma once on in a precompiled header.

Also, if you enable the old_pragma_once on pragma, the once pragma completely ignores path names.

This pragma does not correspond to any panel setting. By default, this pragma is off .

Related information
check_header_flags
faster_pch_gen
flat_include
fullpath_file
fullpath_prepdump
keepcomments
line_prepdump
macro_prepdump
msg_show_lineref
msg_show_realref
notonce
old_pragma_once
pop, push
pragma_prepdump
precompile_target
simple_prepdump
space_prepdump
srcrelincludes
syspath_once