Date: Tue, 4 Jul 2006 03:25:12 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Mike Meyer <mwm-keyword-freebsdhackers2.e313df@mired.org> Cc: James Bailie <jimmy@jamesbailie.com>, freebsd-hackers@freebsd.org, Randall Hyde <randyhyde@earthlink.net> Subject: Re: getc in BSD (was FLEX issues) Message-ID: <20060704002512.GA91588@gothmog.pc> In-Reply-To: <17577.45340.818482.432245@bhuda.mired.org> References: <16887068.1151618963387.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net> <20060630081019.GB734@turion.vk2pj.dyndns.org> <002501c69ecf$5967c6b0$6302a8c0@pentiv> <44A9AC43.3090606@jamesbailie.com> <17577.45340.818482.432245@bhuda.mired.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2006-07-03 20:06, Mike Meyer <mwm-keyword-freebsdhackers2.e313df@mired.org> wrote: > In <44A9AC43.3090606@jamesbailie.com>, James Bailie <jimmy@jamesbailie.com> typed: > > Randall Hyde wrote: > > > This kind of gives me the impression that "getc" is defined a bit > > > differently under FreeBSD than other environments? Any ideas? > > Yes. It's defined as a macro. > > Linux says that getc "may be implemented as a macro". Anything that > needs a function should be using fgetc, not getc. But The C99 standard (actually the latest public draft[1]) allows getc() to be a macro: [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf from http://www.open-std.org/jtc1/sc22/wg14/www/standards | §7.19.7.5 The getc function | | Synopsis | | 1 #include <stdio.h> | int getc(FILE *stream); | | Description | | 2 The getc function is equivalent to fgetc, except that if it is | implemented as a macro, it may evaluate stream more than once, | so the argument should never be an expression with side | effects. This means one shouldn't depend on getc() being a function.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060704002512.GA91588>