I've read that there is some compiler optimization when using #pragma once
which can result in faster compilation. I recognize that is non-standard, and thus could pose a cross-platform compatibility issue.
Is this something that is supported by most modern compilers on non-windows platforms (gcc)?
I want to avoid platform compilation issues, but also want to avoid the extra work of fallback guards:
#pragma once #ifndef HEADER_H #define HEADER_H ... #endif // HEADER_H
Should I be concerned? Should I expend any further mental energy on this?
Definition of is (Entry 1 of 4) present tense third-person singular of be. dialectal present tense first-person and third-person singular of be. dialectal present tense plural of be.
Is is what is known as a state of being verb. State of being verbs do not express any specific activity or action but instead describe existence. The most common state of being verb is to be, along with its conjugations (is, am, are, was, were, being, been). As we can see, is is a conjugation of the verb be.
Definition of in use : being used All of the computers are currently in use.
Cambridge. / (ˈkeɪmbrɪdʒ) / noun. a city in E England, administrative centre of Cambridgeshire, on the River Cam: centred around the university, founded in the 12th century: electronics, biotechnology.
#pragma once
does have one drawback (other than being non-standard) and that is if you have the same file in different locations (we have this because our build system copies files around) then the compiler will think these are different files.
Using #pragma once
should work on any modern compiler, but I don't see any reason not to use a standard #ifndef
include guard. It works just fine. The one caveat is that GCC didn't support #pragma once
before version 3.4.
I also found that, at least on GCC, it recognizes the standard #ifndef
include guard and optimizes it, so it shouldn't be much slower than #pragma once
.
If 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