473,412 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

#pragma once in ISO standard yet?


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?

Thanks...
Dec 12 '07 #1
26 3769
Rick <re****************@spam.nowrote in
news:h9********************************@4ax.com:
>
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?

If it's either language it would be C++.

Try asking in comp.std.c++

--
Tomás Ó hÉilidhe
Dec 12 '07 #2
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?

Thanks...
No, it is not in the standard. Many compilers implement this
but it is not (yet) standard

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Dec 12 '07 #3
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?
You have been told wrong for C.

--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Dec 12 '07 #4
Rick wrote:
I'm told that "#pragma once" has made it into the ISO
standard for either C or C++.
Did you mean neither? It isn't in C. I doubt it's in C++.
I can't find any reference to that anywhere.
Ask the person who told you to supply evidence.

jacob navia <ja...@nospam.comwrote:
No, it is not in the standard. Many compilers implement
this but it is not (yet) standard
Because many compilers implement it differently. The normal
include guard mechanism may be klunky, but at least the
programmer always knows _exactly_ what the preprocessor can
and will do with it.

--
Peter
Dec 13 '07 #5
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

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Dec 13 '07 #6
jacob navia 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?

No, it is not in the standard. Many compilers implement this
but it is not (yet) standard
Wrong. It is in the C99 standard.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Dec 13 '07 #7
CBFalconer <cbfalco...@yahoo.comwrote:
jacob navia 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. ...
No, it is not in the standard. Many compilers implement
this but it is not (yet) standard

Wrong. It is in the C99 standard.
Chapter and verse, please.

Note the OP is talking specifically about #pragma once, not
merely #pragma.

--
Peter
Dec 13 '07 #8
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
What the OP wanted was more like

grep "#pragma" n869.txt | grep once

Which outputs a whole not of nothing....

--
Ian Collins.
Dec 13 '07 #9
CBFalconer wrote:
jacob navia 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?
No, it is not in the standard. Many compilers implement this
but it is not (yet) standard

Wrong. It is in the C99 standard.
Since all the C99 standard pragmas begin with
#pragma STDC
it is very difficult for
#pragma once
to be a C99 standard pragma. Would you care to share _where_ in the
standard you think this is? There are only three standard pragmas,
FP_CONTRACT, FENV_ACCESS, and CX_SELECTED_RANGE. None of them is
spelled "once".
Dec 13 '07 #10
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?

Dec 13 '07 #11
On Wed, 12 Dec 2007 16:07:38 -0500, Rick <re****************@spam.no>
wrote in comp.lang.c:
>
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
Dec 13 '07 #12
Martin Ambuhl wrote:
CBFalconer wrote:
>jacob navia 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?

No, it is not in the standard. Many compilers implement this
but it is not (yet) standard

Wrong. It is in the C99 standard.

Since all the C99 standard pragmas begin with
#pragma STDC
it is very difficult for
#pragma once
to be a C99 standard pragma. Would you care to share _where_ in the
standard you think this is? There are only three standard pragmas,
FP_CONTRACT, FENV_ACCESS, and CX_SELECTED_RANGE. None of them is
spelled "once".
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.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Dec 14 '07 #13
James Kuyper wrote:
>
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.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Dec 14 '07 #14
CBFalconer said:
Martin Ambuhl wrote:
>CBFalconer wrote:
>>jacob navia 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?

No, it is not in the standard. Many compilers implement this
but it is not (yet) standard

Wrong. It is in the C99 standard.

Since all the C99 standard pragmas begin with
#pragma STDC
it is very difficult for
#pragma once
to be a C99 standard pragma. Would you care to share _where_ in the
standard you think this is? There are only three standard pragmas,
FP_CONTRACT, FENV_ACCESS, and CX_SELECTED_RANGE. None of them is
spelled "once".

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.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Dec 14 '07 #15
CBFalconer wrote:
James Kuyper wrote:

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.
Dec 14 '07 #16
Al Balmer <al******@att.netwrote:
>
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
Dec 14 '07 #17
Richard Heathfield wrote:
CBFalconer said:
>Martin Ambuhl wrote:
>>CBFalconer wrote:
jacob navia 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?
>
No, it is not in the standard. Many compilers implement this
but it is not (yet) standard

Wrong. It is in the C99 standard.

Since all the C99 standard pragmas begin with
#pragma STDC
it is very difficult for
#pragma once
to be a C99 standard pragma. Would you care to share _where_ in the
standard you think this is? There are only three standard pragmas,
FP_CONTRACT, FENV_ACCESS, and CX_SELECTED_RANGE. None of them is
spelled "once".

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.
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".

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 14 '07 #18
la************@siemens.com wrote:
Al Balmer <al******@att.netwrote:
>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.
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 */

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 14 '07 #19
ja*********@verizon.net wrote:
CBFalconer wrote:
>James Kuyper wrote:
>>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.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 14 '07 #20
CBFalconer <cb********@yahoo.comwrites:
la************@siemens.com wrote:
>Al Balmer <al******@att.netwrote:
>>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.

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.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Dec 14 '07 #21
Ben Pfaff wrote:
CBFalconer <cb********@yahoo.comwrites:
>la************@siemens.com wrote:
>>Al Balmer <al******@att.netwrote:

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.

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.
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.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 15 '07 #22
CBFalconer <cb********@yahoo.comwrites:
James Kuyper wrote:
>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
[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.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Dec 15 '07 #23
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.
Dec 15 '07 #24
Keith Thompson wrote:
>
.... 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.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 15 '07 #25
CBFalconer wrote:
Keith Thompson wrote:
... 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. :-)

In bridge terms, I would rather call your offence here, a revoke (not
following suit), plus objecting to a valid claim... loudly. :P
--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Dec 15 '07 #26
Tor Rustad wrote:
CBFalconer wrote:
>Keith Thompson wrote:
... 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. :-)

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. :-)

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Dec 15 '07 #27

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jacob Jensen | last post by:
Hi I have a problem creating C++ code that is multiplatform compilable. My problem is using the "#pragma once" directive which can be used by microsoft Visual Studio pre-compiler but which gives...
6
by: Shri | last post by:
Can anybody tell me where i can find a detailed document on #pragma .... --shri
15
by: muttaa | last post by:
Hello all, I'm a beginner in C...May i like to know the difference between a #pragma and a #define.... Also,yet i'm unclear what a pragma is all about as i can find topics on it only in...
187
by: Lasse Espeholt | last post by:
Hi... I am relativ new to the impressive and powerfull C language, but i thinks it is obsolete... The idea with header/source files where methods can clash into eachother i don't like... Look...
7
by: Studlyami | last post by:
Okay I have been wondering this for a while now. I am a little confused on the difference between these two defines #pragma once & #ifndef. From my understanding #pragma is compiler...
4
by: Rick | last post by:
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? ...
5
by: raashid bhatt | last post by:
What is #pragma once used for and what is #WIN#@_LEN_AND_MEAN
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.