Fri 10 Aug 2012 10:01:17 AM UTC, original submission:
The POSIX standard for make includes a number of predefined macros, including
CC=c99
where c99 is an ISO C99-compliant compiler. On a typical GNU system, c99 is a script that runs gcc -std=c99 ..., which fits the bill.
GNU make uses CC=cc, which on a GNU system will be a link to GCC, which still doesn't use the 1999 standard by default.
Even if there is a specific reason for the use of CC=cc instead of CC=c99 (and if so, I'd be interested to hear why), POSIX specifies that by adding a dummy target of .POSIX, make shall conform to the standard, so users that explicitly add that target should see CC=c99.
Here is a shell script to create a C99 program and a makefile that requests POSIX standards compliance. When make runs on the last line, you'll get errors about GCC not running in c99 mode.
cat > ninetynine.c << "-----"
#include <stdio.h>
int main(){
for (int i=0; i< 10; i++) printf("Hello.\n");
}
-----
cat > makefile << "-----"
CFLAGS=-g -Wall
#use the default build rule.
ninetynine:
#This rule requests standards-compliant behavior from make
.POSIX:
-----
make
|