[gccsdk] ttystate constant missing?

Martin Wuerthner martin at mw-software.com
Thu Feb 9 05:08:43 PST 2012

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 Wuerthner          MW Software          martin at mw-software.com

More information about the gcc mailing list