help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %option stdinit


From: Hans-Bernhard Broeker
Subject: Re: %option stdinit
Date: Wed, 6 Mar 2002 17:04:16 +0100 (MET)

On Wed, 6 Mar 2002, W. L. Estes wrote:

> Anyone have any thoughts on this?

The reporter is correct.  stdin and stdout are not required to be
constants usable to initialize a FILE * with, so flex shouldn't do that.
This has been so ever since the 1989 ANSI C standard, and the C99 revision
didn't change that.  Straight from the horse's mouth (7.19.1#3 of C99
draft 3, but wording unchanged in ANSI/ISO C89):

               stderr
               stdin
               stdout

       which are expressions of type ``pointer to FILE'' that point
       to  the  FILE  objects  associated,  respectively,  with the
       standard error, input, and output streams.

The important issue that this doesn't mention anything about these
being _constant_ expressions.

The flex skeleton will have to be changed to an equivalent of

        FILE *yyin;
        FILE *yyout;
        
        /* remaining declarations... */

        yyin=stdin;
        yyout=stdout;

-- 
Hans-Bernhard Broeker (address@hidden)
Even if all the snow were burnt, ashes would remain.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]