once

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

Syntax

#pragma once [ on ]

Targets
All platforms.
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 insure that any file is included only once in a source file.

Be aware that when using #pragma once on, precompiled headers might not necessarily transfer from machine to machine and provide the same results. This is because the full paths of included files are stored to distinguish between two distinct files that have identical filenames but different paths. Use the warn_pch_portability pragma to issue a warning when #pragma once on is used in a precompiled header. For more information, see pragma warn_pch_portability.

This pragma does not correspond to any panel setting. The default setting is off.