PDA

View Full Version : Header guards


Duane
2007.04.17, 08:42 PM
Well, it would seem that "#pragma once" is the better choice, especially because of speed for compiling and the reduced chance for error, but gcc has listed it as "obsolete." Are the traditional "#ifndef" header guards better, or is the #pragma option the good route?

bronxbomber92
2007.04.17, 09:01 PM
I believe the #pragma once technique varies from compiler to compiler, so you're not garunteed it will work everywhere.

OneSadCookie
2007.04.17, 09:42 PM
#pragma once is supported in every C/C++ compiler I've ever used (GCC, MSVC, XLC, ICC, CW).

GCC were about to phase out #pragma once and #import because they were broken, but Apple fixed them, and I believe they're unlikely to go away now.

Duane
2007.04.17, 10:30 PM
The god spoke, and the peasants wept with joy, the kings proclaimed festivals accross their kingdoms, and "#pragma once" was used throughout the land.
(Damn I'm tired).

wyrmmage
2007.04.24, 02:59 PM
The god spoke, and the peasants wept with joy, the kings proclaimed festivals accross their kingdoms, and "#pragma once" was used throughout the land.
(Damn I'm tired).

:lol:

I always used #infdef myself, but just because I learned about them first :P
-wyrmmage