#pragma once in ISO standard yet?

J

Jack Klein

I'm told that "#pragma once" has made it into the ISO standard for

You've multiposted this question in several groups over the past 24
hours.

Who told you this? What qualifications to they have that you should
believe them? If they are so knowledgeable, can't they provide you
with a reference?
either C or C++. I can't find any reference to that anywhere. If
it's true, do any of you have a reference I can use?

No, it's not true.
Thanks...

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
R

Richard Heathfield

CBFalconer said:
I extracted all occurences of "#pragma" in N869 in another
article. If you really want the " once" part it is missing, but
the data is there.

Chuck, the whole context is quoted above. The question relevant to this
group is whether "#pragma once" is part of the C Standard. It is not
disputed that #pragma is part of the Standard. You claimed that Jacob
Navia was *wrong* to say that "#pragma once" is not part of the Standard,
but you have not substantiated that claim by citing the part of the
Standard in which "#pragma once" appears - and indeed you appear to
recognise that this is not possible (because it isn't actually there).

In fact, the Standard does not define "#pragma once" at all. With the three
exceptions that Martin Ambuhl pointed out, the Standard doesn't define any
#pragmas whatsoever. You have therefore incorrectly "corrected" Jacob
Navia, and therefore - by the conventions of this group which you are so
quick to attempt to enforce and yet so reluctant to observe - you owe him
an apology.
 
J

jameskuyper

CBFalconer said:
James said:
Rick wrote:
I'm told that "#pragma once" has made it into the ISO standard for
either C or C++. I can't find any reference to that anywhere. If
it's true, do any of you have a reference I can use?

For example, from N869.txt:

[1] c:\stds>cat n869.txt | grep -n #pragma
9468: #pragma STDC FP_CONTRACT on-off-switch
9469: #pragma STDC FENV_ACCESS on-off-switch
9470: #pragma STDC CX_LIMITED_RANGE on-off-switch
9588: #pragma listing on "..\listing.dir"
10114: #pragma STDC CX_LIMITED_RANGE on-off-switch
11136: #pragma STDC FENV_ACCESS on-off-switch
11179: #pragma STDC FENV_ACCESS ON
11192: placed invocation of #pragma STDC FENV_ACCESS ON.165)
11208: #pragma STDC FENV_ACCESS ON pragma, and assuming the
11338: #pragma STDC FENV_ACCESS ON
11405: #pragma STDC FENV_ACCESS ON
11526: #pragma STDC FENV_ACCESS ON
12343: #pragma STDC FP_CONTRACT on-off-switch
24253: #pragma STDC CX_LIMITED_RANGE on-off-switch
24349: #pragma STDC FENV_ACCESS on-off-switch
24452: #pragma STDC FP_CONTRACT on-off-switch
25641: #pragma STDC FENV_ACCESS ON
25680: #pragma STDC FENV_ACCESS ON
25752: #pragma STDC FENV_ACCESS ON
26310: #pragma STDC FENV_ACCESS ON
26461: #pragma STDC FENV_ACCESS ON
26514: #pragma STDC FENV_ACCESS ON
26564: #pragma STDC FENV_ACCESS ON
26825: #pragma STDC FP_CONTRACT OFF
26888: #pragma STDC FP_CONTRACT OFF
27783: -- An unrecognized #pragma directive is encountered
28363: -- A non-STDC #pragma preprocessing directive that is
28367: -- A #pragma STDC preprocessing directive does not match
29051: -- The behavior on each recognized non-STDC #pragma
29522: #pragma preprocessing directive, 6.10.6

I don't see "#pragma once" anywhere in that list. If my eyes are
deceiving me, could you do something to make the location of the
word "once" more obvious?

Did you thing that grep would miss such an occurence? It didn't.

No, I think you responded to a question about "#pragma once" with an
answer about "#pragma". That was either pointless, or rude, depending
upon whether or not you were expecting us to do the follow-up "grep
once" that you should have performed. If you did expect it, you
compounded the rudeness by not explaining that fact.
 
L

lawrence.jones

Al Balmer said:
Don't worry, "#pragma once" is not in the actual, real, official C99
standard, either.

It may be worth noting that one good reason that it's not there is that
it's fairly easy for the preprocessor to do that optimization itself
without any help from the user. All it has to do is note whether the
entire (non-whitespace) content of the header is protected by a macro
and, if so, make note of it so that if a later #include is seen for the
same header and the macro is defined, it can simply skip the include
processing. The GNU preprocessor has worked that way for a very long
time.

-Larry Jones

It's not denial. I'm just very selective about the reality I accept.
-- Calvin
 
C

CBFalconer

Richard said:
CBFalconer said:

Chuck, the whole context is quoted above. The question relevant to this
group is whether "#pragma once" is part of the C Standard. It is not
disputed that #pragma is part of the Standard. You claimed that Jacob
Navia was *wrong* to say that "#pragma once" is not part of the Standard,
but you have not substantiated that claim by citing the part of the
Standard in which "#pragma once" appears - and indeed you appear to
recognise that this is not possible (because it isn't actually there).

In fact, the Standard does not define "#pragma once" at all. With the three
exceptions that Martin Ambuhl pointed out, the Standard doesn't define any
#pragmas whatsoever. You have therefore incorrectly "corrected" Jacob
Navia, and therefore - by the conventions of this group which you are so
quick to attempt to enforce and yet so reluctant to observe - you owe him
an apology.

Apology delivered. Excuse: I was operating on the misconception
that the sequence was about the existence of the "#pragma" phrase
in the language (as shown by the grep instruction I used), not the
phrase "#pragma once".
 
C

CBFalconer

It may be worth noting that one good reason that it's not there is
that it's fairly easy for the preprocessor to do that optimization
itself without any help from the user. All it has to do is note
whether the entire (non-whitespace) content of the header is
protected by a macro and, if so, make note of it so that if a
later #include is seen for the same header and the macro is
defined, it can simply skip the include processing. The GNU
preprocessor has worked that way for a very long time.

That will usually, but not always, work, and you need to be aware
of how and why it can fail. Try the following:

/* file foo.h */
#ifndef H_foo_h
# define H_foo_h
/* foo.h content here */
# endif
/* end file foo.h */

/* file main.c */
#define H_foo_h
#include "foo.h"
/* whatever, is missing foo.h content */
int main(void) {foo(); return 0);
/* end file main.c */
 
C

CBFalconer

CBFalconer said:
James said:
CBFalconer wrote:
Rick wrote:

I'm told that "#pragma once" has made it into the ISO standard for
either C or C++. I can't find any reference to that anywhere. If
it's true, do any of you have a reference I can use?

For example, from N869.txt:

[1] c:\stds>cat n869.txt | grep -n #pragma
9468: #pragma STDC FP_CONTRACT on-off-switch
9469: #pragma STDC FENV_ACCESS on-off-switch
9470: #pragma STDC CX_LIMITED_RANGE on-off-switch
9588: #pragma listing on "..\listing.dir"
10114: #pragma STDC CX_LIMITED_RANGE on-off-switch
11136: #pragma STDC FENV_ACCESS on-off-switch
11179: #pragma STDC FENV_ACCESS ON
11192: placed invocation of #pragma STDC FENV_ACCESS ON.165)
11208: #pragma STDC FENV_ACCESS ON pragma, and assuming the
11338: #pragma STDC FENV_ACCESS ON
11405: #pragma STDC FENV_ACCESS ON
11526: #pragma STDC FENV_ACCESS ON
12343: #pragma STDC FP_CONTRACT on-off-switch
24253: #pragma STDC CX_LIMITED_RANGE on-off-switch
24349: #pragma STDC FENV_ACCESS on-off-switch
24452: #pragma STDC FP_CONTRACT on-off-switch
25641: #pragma STDC FENV_ACCESS ON
25680: #pragma STDC FENV_ACCESS ON
25752: #pragma STDC FENV_ACCESS ON
26310: #pragma STDC FENV_ACCESS ON
26461: #pragma STDC FENV_ACCESS ON
26514: #pragma STDC FENV_ACCESS ON
26564: #pragma STDC FENV_ACCESS ON
26825: #pragma STDC FP_CONTRACT OFF
26888: #pragma STDC FP_CONTRACT OFF
27783: -- An unrecognized #pragma directive is encountered
28363: -- A non-STDC #pragma preprocessing directive that is
28367: -- A #pragma STDC preprocessing directive does not match
29051: -- The behavior on each recognized non-STDC #pragma
29522: #pragma preprocessing directive, 6.10.6

I don't see "#pragma once" anywhere in that list. If my eyes are
deceiving me, could you do something to make the location of the
word "once" more obvious?

Did you thing that grep would miss such an occurence? It didn't.

No, I think you responded to a question about "#pragma once" with an
answer about "#pragma". That was either pointless, or rude, depending
upon whether or not you were expecting us to do the follow-up "grep
once" that you should have performed. If you did expect it, you
compounded the rudeness by not explaining that fact.

No, I had the mistaken idea that everything was about the existence
of #pragma in standard C, and as a result I have wasted many
innocent electrons, peoples time, bandwidth, etc. etc. Apologies
tendered.
 
B

Ben Pfaff

CBFalconer said:
That will usually, but not always, work, and you need to be aware
of how and why it can fail. Try the following:

/* file foo.h */
#ifndef H_foo_h
# define H_foo_h
/* foo.h content here */
# endif
/* end file foo.h */

/* file main.c */
#define H_foo_h
#include "foo.h"
/* whatever, is missing foo.h content */
int main(void) {foo(); return 0);
/* end file main.c */

This code will have the same effect whether the compiler includes
this optimization or not.
 
C

CBFalconer

Ben said:
This code will have the same effect whether the compiler includes
this optimization or not.

Yes, but if the programmer is depending on some "pragma once" to
effect the action, or on gcc magic of recognizing the control
variable, he may be hard put to understand the fault.
 
K

Keith Thompson

CBFalconer said:
James said:
CBFalconer said:
Rick wrote:
I'm told that "#pragma once" has made it into the ISO standard for
either C or C++. I can't find any reference to that anywhere. If
it's true, do any of you have a reference I can use?

For example, from N869.txt:

[1] c:\stds>cat n869.txt | grep -n #pragma
9468: #pragma STDC FP_CONTRACT on-off-switch
9469: #pragma STDC FENV_ACCESS on-off-switch
9470: #pragma STDC CX_LIMITED_RANGE on-off-switch [SNIP]
29051: -- The behavior on each recognized non-STDC #pragma
29522: #pragma preprocessing directive, 6.10.6

I don't see "#pragma once" anywhere in that list. If my eyes are
deceiving me, could you do something to make the location of the
word "once" more obvious?

Did you thing that grep would miss such an occurence? It didn't.

So your point in posting that grep listing was to demonstrate that
"#pragma once" *isn't* in C99?

I, and I think everyone else who read your article, thought either
that you were trying to demonstrate that "#pragma once" *is* in C99,
or that you had misunderstood the question and were demonstrating that
"#pragma" is in C99. This was strongly reinforced by the fact that
the article to which you replied asked for a reference to "#pragma
once", and you posted an excerpt from the standard -- *without*
mentioning that the word "once" doesn't appear in the listing.
(Apparently you expected each reader to slog through the entire
listing.)

Your response was extraordinarily unclear. Simply stating your
conclusion would have made it clear.
 
J

James Kuyper

CBFalconer wrote:
....
No, I had the mistaken idea that everything was about the existence
of #pragma in standard C, and as a result I have wasted many
innocent electrons, peoples time, bandwidth, etc. etc. Apologies
tendered.

Apology accepted. I thought it might be something like that.
 
C

CBFalconer

Keith said:
.... snip ...

Your response was extraordinarily unclear. Simply stating your
conclusion would have made it clear.

I do tend to be terse. I have also had people object to my early
claims at the bridge table. :) But there there is a clear and
immediate rule for resolution. I can't claim I will never make
that mistake again, but I will make attempts.
 
T

Tor Rustad

CBFalconer said:
Keith Thompson wrote:
... snip ...

I do tend to be terse. I have also had people object to my early
claims at the bridge table. :)


In bridge terms, I would rather call your offence here, a revoke (not
following suit), plus objecting to a valid claim... loudly. :p
 
C

CBFalconer

Tor said:
In bridge terms, I would rather call your offence here, a revoke (not
following suit), plus objecting to a valid claim... loudly. :p

I shall refrain from arguing and calling the director. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top