Article View: comp.std.c
Article #2111Re: FILE *yyin=stdin; not ANSI-C??
From: Jos Horsmeier
Date: Fri, 09 Oct 1992 19:07
Date: Fri, 09 Oct 1992 19:07
23 lines
1230 bytes
1230 bytes
In article <Bvv6Gn.KEn@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:
|In article <1992Oct8.220811.7882@utwente.nl> emmerik@utrcu1.civ.utwente.nl (Emmerik P.J.L. van) writes:
|>The following looks to me perfectly legal ANSI-C code.
|>
|>FILE *yyin = {stdin}, *yyout = {stdout};
|
|Sorry, it's not. Nothing in ANSI C promises that stdin and stdout are
|constants. Therefore they cannot (portably) be used to initialize
|extern/static variables.
You're right, but the ANSI C standard _does_ `promise' that stdin and
stdout are `expressions of type ``pointer to FILE'' that point to the
FILE objects associated [...]'
So, the original poster can solve his/her problem by moving the assignments
away from the initialization code and simply do an assignment like:
FILE *yyin, *yyout;
/* ... */
yyin= stdin; yyout= stdout;
kind regards,
Jos aka jos@and.nl
Technical Details
Message-ID:
<3586@dozo.and.nl>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!and!josReferences:
<1992Oct8.220811.7882@utwente.nl> <Bvv6Gn.KEn@zoo.toronto.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!and!jos From: jos@and.nl (Jos Horsmeier) Newsgroups: comp.std.c Subject: Re: FILE *yyin=stdin; not ANSI-C?? Message-ID: <3586@dozo.and.nl> Date: 9 Oct 92 19:07:51 GMT References: <1992Oct8.220811.7882@utwente.nl> <Bvv6Gn.KEn@zoo.toronto.edu> Organization: AND Software BV Rotterdam Lines: 23