I'm writing some serial code on a raspberry pi and switched to C99. When I did I started getting the error "error: ‘CRTSCTS’ undeclared (first use in this function)"
$ c99 -M serial01.c | grep termios.h
/usr/include/termios.h /usr/include/arm-linux-gnueabihf/bits/termios.h \
$ gcc -M serial01.c | grep termios.h
/usr/include/termios.h /usr/include/arm-linux-gnueabihf/bits/termios.h \
using -M reveals 2 termios.h headers. the former does not contain a definition for CRTSCTS and the latter does.
I assume the standard c89 is using the good one and c99 not but I'm not sure since the result of the -M call is identical. Can anyone explain to me why this is happening when I switch to C99 and how to fix it?
-std=gnu99
is the solution. More detailed below.Result of the gcc/c99 -M call is identical but it does not mean anything! The explanation of this behavior are preprocessor macros (specifically GNU extensions, like said Mat).
In detail:
This behavior is the same for c99 and gnu99!
Like said Cameron, -M output is identical:
CRTSCTS is defined in the bits/termios.h when __USE_MISC is defined
Let's look at __USE_MISC.
First one, features.h, contains definition of __USE_MISC, but only when _BSD_SOURCE or _SVID_SOURCE is defined
and _BSD_SOURCE and _SVID_SOURCE is defined when _GNU_SOURCE or 'nothing' is defined