[gccsdk] ttystate constant missing?

Ron beeb at woosh.co.nz
Thu Feb 9 05:43:54 PST 2012


In message <af81d25e52.martin at bach.planiverse.com>
          Martin Wuerthner <martin at mw-software.com> wrote:

> In message <d6e0ce5e52.beeb at ron1954.woosh.co.nz>
>           Ron <beeb at woosh.co.nz> wrote:
> 
> > In message <2142c95e52.beeb at ron1954.woosh.co.nz>
> >           Ron <beeb at woosh.co.nz> wrote:
> 
> >> I have a compiler error with
> >> static enum { RESET, RAW, CBREAK } ttystate = RESET;
> >> 
> >> It seems that RAW and CBREAK are defined in <sys/ioctl> but there is
> >> nothing around for RESET.
> >> 
> > OK, It compiles if I change the spelling of RAW and CBREAK to an unknown.
> > So it may be that the problem is that those two have been defined, and
> > this function wants to set them at 0, 1, 2 ?
> 
> The above is perfectly valid code, but any perfectly valid code that 
> makes use of identifiers or keywords can be broken by previous 
> #defines. If the file with the above code #includes <sys/ioctl.h>, 
> which #defines RAW and CBREAK as numeric constants, then you get a 
> compiler error because the compiler sees numbers instead of the 
> identifiers RAW and CBREAK in the enum declaration. That is a name 
> conflict between this code and the contents of <sys/ioctl.h>.
> 
> At a guess, the above code was meant to be used as a fallback 
> implementation on platforms that do not have <sys/ioctl.h> available.
> 
> Martin

Yes <sys/ioctl> is included for the library I am building, but there is
probably various implementations of <sys/ioctl also.
I'm not sure wether to change the names in the ttymode.c or to undefine
CBREAK and RAW in <sys/ioctl>. 
If another program in the suite wants to use the names, it may be better
to undefine them in <sys/ioctl> so I can keep them as is.

Thanks for demystifying things a bit, anyway.

Ron M.    




More information about the gcc mailing list