gcc 1.39 and #pragma once

Thaddeus P. Floryan thad at public.BTR.COM
Tue Jun 11 20:15:07 AEST 1991

In article <1991Jun10.040255.4434 at blilly.UUCP> bruce at balilly.UUCP (Bruce Lilly) writes:
>I noticed that the cpp which is part of the gcc 1.39
>binary distribution archived in the att7300 hierarchy
>on osu-cis does not support the
>#pragma once
>preprocessor command. Version 1.35 certainly did, and
>I believe 1.37 did also.
>Of course, the documentation is not part of the binary
>package, hence the following question:
>Has #pragma once been dropped by FSF, or is it a compile-time
>option which was left out of the binary archived on
>osu-cis, or is it some sort of bug in 1.39 which causes
>it to not recognize #pragma?

>From the cpp docs per the Info mode of GNU EMACS:

	The `#pragma' command is specified in the ANSI standard to have an
	arbitrary implementation-defined effect.  In the GNU C preprocessor,
	`#pragma' commands are ignored, except for `#pragma once' (*note
	One drawback of this method is that the preprocessor must scan the
	input file completely in order to determine that all of it is to be
	ignored.  This makes compilation slower.  You can avoid the delay by
	inserting the following command near the beginning of file *in
	addition to the conditionals described above*:

	     #pragma once

	This command tells the GNU C preprocessor to ignore any future
	commands to include the same file (whichever file the `#pragma'
	appears in).

	You should not *rely* on `#pragma once' to prevent multiple inclusion
	of the file.  It is just a hint, and a nonstandard one at that.  Most
	C compilers will ignore it entirely.  For this reason, you still need
	the conditionals if you want to make certain that the file's contents
	are not included twice.

	Note that `#pragma once' works by file name; if a file has more than
	one name, it can be included once under each name, even in GNU CC,
	despite `#pragma once'.

Gee, not too long ago any use of #smegma (or #fragme, #pragma, whatever :-)
would result in the gnu-cpp attempting to execute several games in sequence,
then abort if the games were not found on the system; sigh, times have changed.

Sorry, but I haven't loaded-up 1.39 yet since I just noticed 1.40 was announced
in the gnu.* newsgroups.  Looks to me like "#pragma once" is best forgotten and
the more-standard (and portable) techniques used instead (e.g.  #ifndef foo_sym
#define foo_sym ... ) which'll work with any C on any machine.

Thad Floryan [ thad at btr.com (OR) {decwrl, mips, fernwood}!btr!thad ]

More information about the Comp.sys.3b1 mailing list