jdc@naucse.UUCP (John Campbell) (05/11/88)
Well I just finished making flex (Fast lex from Vern Paxson) work on
VMS. The reason for this posting is to raise a 'C' question and to
let people know flex will run on VMS.
The 'C' question:
Flex has the following global line:
FILE *yyin=stdin, *yyout=stdout;
which does not work at compile time on VMS. In other words, it appears
the compiler does not treat stdin as a constant--it's value is known only
at run-time. (VMS stdio.h says "extern noshare FILE *stdin;.) To work
around this I had to concote a fake main():
FILE *yyin, *yyout;
main()
{
yyin = stdin; yyout = stdout;
Question: Is my compiler deficient? Is the initialization done in flex
suppose to work in ANSI C?
Flex on VMS:
For those interested, the following changes were done to make flex work on
VMS: 1) 2 macro names > 31 characters where changed, 2) some file names were
corrected to fit the VMS file system, 3) the yyin problem mentioned above
was worked around, 4) bzero was defined as OTS$MOVEC5, and 5) unlink() was
replaced with delete().
If there is enough interest I can post a SEARCH for VMS (300 lines)
indicating how the original was changed. I'm afraid my port is only a
start toward folding VMS support back into the original. Anyone wanting
to improve on my effort is more than welcome, but I fear the unix community
may be less than sympathetic to those of us stuck on VMS :-).
MUCH THANKS TO VERN PAXSON, KEVIN GONG, VAN JACOBSON, ET.AL.!!!!!!
--
John Campbell ...!arizona!naucse!jdc
unix? Sure send me a dozen, all different colors.scjones@sdrc.UUCP (Larry Jones) (05/12/88)
In article <690@naucse.UUCP>, jdc@naucse.UUCP (John Campbell) writes: > The 'C' question: > Flex has the following global line: > > FILE *yyin=stdin, *yyout=stdout; > > which does not work at compile time on VMS. In other words, it appears > the compiler does not treat stdin as a constant--it's value is known only > at run-time. (VMS stdio.h says "extern noshare FILE *stdin;.) To work According to the latest ANSI draft (and many of the previous ones), stdin and friends are simply expressions and not necessarily constant expressions. Thus, they may not be used portably to initialize objects with static storage duration. So, the compiler's OK, flex is not maximally portable (as you found out). ---- Larry Jones UUCP: ...!sdrc!scjones SDRC AT&T: (513) 576-2070 2000 Eastman Dr. BIX: ltl Milford, OH 45150 "When all else fails, read the directions."
wcs@skep2.ATT.COM (Bill.Stewart.<ho95c>) (05/20/88)
In article <278@sdrc.UUCP> scjones@sdrc.UUCP (Larry Jones) writes: :In article <690@naucse.UUCP>, jdc@naucse.UUCP (John Campbell) writes: :> The 'C' question: :> Flex has the following global line: :> FILE *yyin=stdin, *yyout=stdout; :> which does not work at compile time on VMS. In other words, it appears :> the compiler does not treat stdin as a constant--it's value is known only :> at run-time. (VMS stdio.h says "extern noshare FILE *stdin;.) To work : :According to the latest ANSI draft (and many of the previous ones), stdin and :friends are simply expressions and not necessarily constant expressions. Thus, :they may not be used portably to initialize objects with static storage :duration. So, the compiler's OK, flex is not maximally portable (as you If the compiler's OK, what's this "noshare" business? It's been a while since I've seen the ANSI C draft, but I don't remember that being in it - it looks kind of like noalias? (Noalias had to go, and did - it was non-negotiable.) Also, something you declare to be extern shouldn't be assumed to be constant. So both are somewhat non-portable. -- # Thanks; # Bill Stewart, AT&T Bell Labs 2G218, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs # skep2 is a local machine I'm trying to turn into a server. Please send # mail to ho95c or ho95e instead. Thanks.