Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!cmcl2!nrl-cmf!ames!oliveb!3comvax!bridge2!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.lang.c Subject: Re: getch() and getche() in MSC 4.0 Keywords: *##%@^!&ing functions! Message-ID: <305@auspex.UUCP> Date: 25 Oct 88 19:16:40 GMT References: <10508@dartvax.Dartmouth.EDU> <10523@dartvax.Dartmouth.EDU> <7357@ihlpl.ATT.COM> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 47 >Stupid, hell. Don't you wish that every C system had some standard, >easy way to check which "fcns" are macros? Many of them do; it's called "the manual". For instance, from SunOS 4.0 (I suspect these items go back to the V7 documentation): DESCRIPTION getc() returns the next character (that is, byte) from the named input stream, as an integer. It also moves the file pointer, if defined, ahead one character in stream. getchar() is defined as getc(stdin). getc and getchar are macros. ... BUGS Because it is implemented as a macro, getc() treats a stream argument with side effects incorrectly. In particular, getc(*f++) does not work sensibly. fgetc() should be used instead. What do you mean by "check"? Do you mean #if "getchar is a macro" code that works if "getchar" is a macro... #else code that doesn't... #endif If so, try #ifdef getchar code that works if "getchar" is a macro... #else code that doesn't... #endif although it would be better to just write code that works if "getchar" is a macro... and be done with it. >That lint warned you about such problems? Well, yeah, it'd be nice if "lint" warned about attempts to dereference null pointers, too, and misspellings in character strings, and....