Talk:Pragma once

From Wikipedia, the free encyclopedia

"It is a Microsoft specific C/C++ preprocessor directive."

I don't think it is Microsoft specific, it is used by CodeWarrior also, and there is support in GCC for Darwin (probably for combatibility with CodeWarrior which was predominant before OSX/gcc on Macintosh) --unsigned comment

Not only that, but the only info on its origin I can find suggests that it was first recognised by GCC 1.35, or so sayeth Ian Lance Taylor. Of course, GCC went on to deprecate its baby, but it's currently fully supported again. Just considered non-portable & thus disliked. Does anyone have any information to the contrary? If not, I think I'll alter the article to say so; I'll leave it a while in case someone does have more information than I. —SirPavlova 19:44, 1 January 2007 (UTC)


#pragma once has worked in GCC since it became un-deprecated in 3.4. It also can improve build speeds on certain compilers even more than regular internal inclusion guards which should probably be mentioned in the article. Also, I don't know why the bulk of this article is spent explaining _MSC_VER. It should just recieve a passing mention.--66.93.225.126 23:44, 2 June 2006 (UTC)

[edit] Cleanup

Attempted to clean up article. Jafet

It still needs a complete rework. The pragma "usually" does something? Does the compiler flip a coin? I know what it means, but only because I already knew what it means.

tidied up just a little to deal with the 'usually' language OMatthews 07:35, 10 October 2006 (UTC)

#pragma once is deprecated by the GCC documentation.[1]

When you go to link you'll see that it incorrect :) GCC documentations said that you shouldn't rely on pragma once in portable programs, but it isn't deprecated

"11.3 Obsolete Features CPP has a number of features which are present mainly for compatibility with older programs. We discourage their use in new code. In some cases, we plan to remove the feature in a future version of GCC." True, it doesn't say exactly which features are slated for removal, versus merely discouraged, but "deprecated" is shorter than "listed as obsolete". :) But you're right; I'll change the wording to "listed as obsolete" until someone can find a definitive source. --Quuxplusone 06:39, 17 December 2006 (UTC)

"the GCC documentation lists #pragma once as an "obsolete" feature." The reference cited, and I have not been able to find one more definitive, warns that #pragma once is non-portable, but nowhere does it say that it is obsolete. In fact it is referred to favorably compared to #import. I changed the wording to reflect this. Gauss256 (talk) 08:18, 7 February 2008 (UTC)


While cleaning this article up, would it be well served if a compiler usage table was given? E.g.

Compiler #pragma once
C++ Builder ?
C++ Compiler No
Comeau C/C++ No
Digital Mars Yes
GCC No
Intel C++ Compiler Yes
Local C compiler ?
MULTI Yes
Open Watcom Yes
PathScale No
PGI Workstation Yes
Portable C Compiler No
ProDev WorkShop Yes
RealView C/C++ Compiler (armcc) ?
SAS/C ?
Sun Studio ?
TenDRA ?
Tiny C Compiler ?
Visual Studio ?
VisualAge ?
XL C/C++ ?
AMPC ?
Nwcc ?
VectorC ?

Note: The above table is an example only. No data should be taken from it. Additional data might include specific versions; if it handles links correctly; and other relevant information. Marshall 14:33, 12 March 2008 (UTC)


A note on the ISO committee’s intentions might also be appropriate. Marshall 14:33, 12 March 2008 (UTC)