
Whereas include guards would still protect from double definitions, #pragma once may or may not treat them as the same file in a compiler-dependent way. Additionally, #pragma once can do the wrong thing if the same file is intentionally copied into several parts of a project, e.g. Compilers may use a heuristic that compares file size, modification time and content. Symbolic links and especially hard links may cause the same file to be found under different names in different directories. Identifying the same file on a file system is not a trivial task. Yet, since include guards appear very often and the overhead of opening files is significant, it is common for compilers to optimize the handling of include guards, making them as fast as #pragma once. In the absence of #include guards around #include directives, the use of #pragma once will improve compilation speed for some compilers since it is a higher-level mechanism the compiler itself can compare filenames or inodes without having to invoke the C preprocessor to scan the header for #ifndef and #endif. Since the pre-processor itself is responsible for handling #pragma once, the programmer cannot make errors which cause name clashes.

Such errors are unlikely to remain undetected but can complicate the interpretation of a compiler error report.
Oncework source manual#
This is more verbose, requires greater manual intervention, and is prone to programmer error as there are no mechanisms available to the compiler for prevention of accidental use of the same macro name in more than one file, which would result in only one of the files being included. This approach minimally ensures that the contents of the include file are not seen more than once. #ifndef GRANDPARENT_H #define GRANDPARENT_H.
