On Wed, 8 Sep 1999, Greg Haerr wrote:
> Basically, the time-honored FILE * constants stdin, stdout, and stderr are no longer
> constant. The offending line is:
>
> FILE *in = stdin;
>
> the compiler is complaining that stdin is no longer a constant.
>
> This problem cropped up in one of the ELKS cmd sources, but I was able to fix it
> more cleanly.
>
> This can be fixed by initializing the "in" variable as the first statement in main(),
> as "in = stdin" and changing the FILE * decl to "FILE *in;".
>
> Does anybody (Rob?) have any comments as to why the C lib guys could have
> done this? It's going to screw up alot of old programs.
I imagine they've made the FILE structures a dynamic resource that's
malloced by the fopen() function. The advantage is that you don't have to
guess how many fd's the open() call is allowed to return or pre-allocate
a huge array of FILE structures. The disadvantage is that without a
little bit of special code you can't predict where stdin/out/err will
exist in memory so they can't be constants. I do the same thing in
bcc's stdio except I have got the special case code for stdin/out/err
so this common practice doesn't break anything.
--
Rob. (Robert de Bath <http://poboxes.com/rdebath>)
<rdebath @ poboxes.com> <http://www.cix.co.uk/~mayday>