Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!VENUS.YCC.YALE.EDU!LEICHTER From: LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) Newsgroups: comp.os.vms Subject: Re: flex (really, re "noshare") Message-ID: <8805260107.AA12954@ucbvax.Berkeley.EDU> Date: 24 May 88 03:15:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 38 :> 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. "noshare" is a VAX C extension to control storage allocation; it is mainly needed when creating shared images --- it says that the variable is to go into a "copy on reference" segment, rather than being shared among all users of the shared image. Since the VAX C run-time library, including all the code for such things as printf, normally lives in a shared library (VAXCRTL.EXE), you can see that stdio had better be "noshare" unless you want everyone on the system writing to the same standard output! "noshare" pre-dates ANSI, which it is certainly not compatible with. It could presumably be replaced with a #pragma or something like "__noshare" to be compatible. Whether it can appear in the declaration of stdin and friends is an interes- ting question. What it comes down to is: Does the ANSI spec guarantee a particular declaration syntax for these things, or does it simply guarantee that some sort of appropriate - but system-specific - definition will be available if stdio.h is included. -- Jerry