James Kuyper
4/15/2011 1:02:00 AM
On 04/14/2011 12:29 PM, Thomas Scrace wrote:
> Hi all,
>
> I am working through K&R, and I got to section 1.9, which includes an example
> that creates a function 'getline'. I duly typed it all up, and compiled it with
> gcc. Surprisingly I got an error telling me of incompatible types for this
> function.
>
> It turns out that GNU's C library now includes a function called getline, and
> since I was including stdio.h, this was the cause of the problem. I recompiled
> using c89, and everything worked fine.
>
> My question is this: should we not make an effort to keep the modern C toolchain
> and library compatible with the great K&R, unless doing so would create an even
> more undesirable outcome?
The key thing to realize is that what gcc implements, by default, is a
language known as Gnu-C. It's derived from C, and has lots of
similarities to C, but it's a significantly different language.
Criticizing Gnu-C for incompatibility with the C language as described
by K&R is only slightly less pointless than criticizing APL for being
incompatible with perl.
In non-default mode, by choosing the right options, you can ask gcc to
perform as a fully-conforming C90 compiler, and with different options
it is a nearly-conforming C99 compiler. The fact that you didn't use
those options was your decision, not something you can hold gcc
responsible for. Gnu-C is gcc's default language because they would
prefer it if if you would use Gnu-C, rather than standard C.
--
James Kuyper