misleading statement in bugs.html#known
Andreas Schwab
schwab@suse.de
Wed Dec 5 14:38:00 GMT 2001
Per Bothner <per@bothner.com> writes:
|> The bugs.html files says 'FILE *yyin = stdin' "will not compile with GNU
|> libc (GNU/Linux libc6), because stdin is not a constant. This was done
|> deliberately, in order for there to be no limit on the number of open FILE
|> objects."
|>
|> The latter has nothing to do with it. It is easy to make stdin be
|> a constant while still having no limit on the number of open FILE
|> objects. For example:
|>
|> extern FILE __stdin;
|> @define stdin (&__stdin)
|>
|> The point is that glibc allows you to *assign* to stdin, so it is
|> no longer constant. This is a questionable feature..
No. The real reason is that using the address of a static object is a
nightmare in context of maintaining binary compatibility. Platforms that
use copy relocations will lose if the size of the FILE type changes.
In any way, the C standard does not *require* stdin to be a constant.
Thus using it as an initializer at file scope is broken no matter what.
Andreas.
--
Andreas Schwab "And now for something
Andreas.Schwab@suse.de completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
More information about the Gcc
mailing list