Friday, April 3, 2009

'getline' is in POSIX 2008 and exposed in stdio.h by default

While using buildroot-avr32-v2.3.0 on Fedora 11, I got this build failure:

linux-]$ make headers_install
<... SNIP ...>
HOSTCC scripts/unifdef
scripts/unifdef.c:209: error: conflicting types for ‘getline’
/usr/include/stdio.h:653: note: previous declaration of ‘getline’ was here

Apparently, 'getline' is now part of POSIX 2008 and is exposed by glibc-2.9.90's stdio.h by default without the user having to declare feature test macros like "#define _XOPEN_SOURCE NNN" or "_GNU_SOURCE".
I pity the kids who are now trying the 'getline' example from
"The C Programming" Chapter 1 and don't know they need to use 'c89' (or 'c99', 'gcc -std=c99 etc) instead of 'gcc'.

Edit: see also: