Path: utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!DG-RTP.DG.COM!meissner From: meissner@DG-RTP.DG.COM (Michael Meissner) Newsgroups: gnu.gcc Subject: Re: cbreak(?) mode and gcc Keywords: gcc, less, scrabble, screen mode Message-ID: <8904281417.AA13699@tiktok.dg.com> Date: 28 Apr 89 14:17:38 GMT References: <1776@leah.Albany.Edu> Sender: daemon@tut.cis.ohio-state.edu Reply-To: Michael Meissner Distribution: gnu Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 57 In article <1776@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes: | Hello, | | I've noticed that programs which need to go into cbreak (I think - the | one that sends chars directly through to the program without a newline | when entered from a terminal) don't work correctly when compiled with | gcc 1.34. This would seem to me to be a function of the library routines | and not the compiler, but both `less' (v97) and `scrabble' (just posted | to c.s.?) exhibit the same behavior - when compiled with cc, they | deal with the keyboard as expected, but with gcc, they do nothing til | return is entered. This seems to come up every so often. Usually this comes about because the include file "/usr/include/sys/ioctl.h" (and others too, but this is the prime culprit) is not compatible with ANSI. Since GCC defaults to the ANSI interpretation, it means that you issue the wrong ioctl. In particular, the following macros are the ones with problems (macros taken from a Sun 3.5 system, since we have one internally): #define _IO(x,y) (IOC_VOID|('x'<<8)|y) #define _IOR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y) #define _IORN(x,y,t) (IOC_OUT|(((t)&IOCPARM_MASK)<<16)|('x'<<8)|y) #define _IOW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y) #define _IOWN(x,y,t) (IOC_IN|(((t)&IOCPARM_MASK)<<16)|('x'<<8)|y) /* this should be _IORW, but stdio got there first */ #define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y) #define _IOWRN(x,y,t) (IOC_INOUT|(((t)&IOCPARM_MASK)<<16)|('x'<<8)|y) /* ... */ #define TIOCSETC _IOW(t,17,struct tchars)/* set special characters */ #define TIOCGETC _IOR(t,18,struct tchars)/* get special characters */ These macros depend on substituting the argument 'x' into the character constant, which is what ANSI disallows. To fix this, you have a few options: 1) Use the -traditional switch, which will tell GCC to do things the old fashioned PCC way; 2) Use the fixincludes script provided with GCC to repair the includes, so they can used with an ANSI compiler. The includes are put into GCC's private directory: /usr/local/lib/gcc-include which GCC searches before /usr/include. I have noticed that the include files that are fixed don't work with non-ANSI compilers or GCC's -traditional switch. -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner If compiles were much Internet: meissner@dg-rtp.DG.COM faster, when would we Old Internet: meissner%dg-rtp.DG.COM@relay.cs.net have time for netnews?