Possible duplicate:#pragma once vs includes defenders?
When should I use #pragma once?
#pragma once
When should I use #ifndef HEADER_H_INCLUDED?
#ifndef HEADER_H_INCLUDED
# ifndef / # define / # endif trick works on any C compiler, and on some of them speeds up the compilation process. The #pragma trick is non-standard and works only with a few C compilers and can lead to different semantics in those that do not support it.
The difference is that the latter is C and the former is not. Never use #pragma once; always use #ifndef.
#ifndef
, #ifndef, , , , , . , #ifndef MYHEADER_H #ifndef _MYHEADER_H.
#ifndef MYHEADER_H
#ifndef _MYHEADER_H
#pragma, ( ) #pragma FP_CONTRACT -CX_LIMITED_RANGE-, .
#pragma
FP_CONTRACT
-CX_LIMITED_RANGE-
#ifndef ilk, C ( ++) , , .
#pragma, C ( ++), . #pragma once , #pragma. , . #ifndef .
#ifndef MYFOO_H #define MYFOO_H /* header information for myfoo.h */ #endif
. , () , . .
#pragma is for the compiler, and the preprocessor should ignore pragmas that it does not understand.