Header guards

Member
Posts: 567
Joined: 2004.07
Post: #1
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?

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #2
I believe the #pragma once technique varies from compiler to compiler, so you're not garunteed it will work everywhere.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
#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.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #4
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).

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 373
Joined: 2006.08
Post: #5
Nayr Wrote: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 Rasp
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Post Reply