splinter icon indicating copy to clipboard operation
splinter copied to clipboard

Use #pragma once instead of traditional include guards

Open gablank opened this issue 10 years ago • 0 comments

Use #pragma once instead of

ifndef THIS_HEADER

define THIS_HEADER

endif // THIS_HEADER

to avoid including headers more than once. This has several benefits, two of them being:

  • Avoid polluting the macro namespace
  • Harder to do something wrong (like defining something different from what youre are #ifndef-ing)

Compiler support: All major (GCC >= 3.4).

See https://en.wikipedia.org/wiki/Pragma_once.

gablank avatar Jan 11 '16 12:01 gablank