Possible Duplicate:
#pragma once vs include guards?
What are the differences (in performance, usability and functionality) in using #pragma once
and #if !defined MYHEADER_INCLUDED_
constructs? Or what is the difference between the two?
Wikipedia has all your answers for this and is easy enough to find
From the article
In the C and C++ programming languages,
#pragma once
is a non-standard but widely supported preprocessor directive designed to cause the current source file to be included only once in a single compilation.Thus,
#pragma once
serves the same purpose as#include
guards, but with several advantages, including: less code, avoiding name clashes, and improved compile speed.
It has a more in-depth look at the advantages and disadvantages in the article. If you are really interested I suggest you read it completely, not just the blurb above.
#pragma once
implementation compiles faster, because it's intent is cleardefined
version has of course wider uses too, and if used carefully will allow to check in another file if the former was included (for conditional compilation for example)#pragma once
-- however, this is a non-standard extensionIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With