There is no mention of a AC_PROG_CC_C11
analogue to AC_PROG_CC_C99
.
How can I get my autotools project to put --std=c11
into CFLAGS
?
Most simply by putting
CFLAGS+=" -std=c11"
into your configure.ac
(in addition to AC_PROG_CC
). configure.ac
is a template for a shell script, so you can simply put shell code in it. In fact, all the AC_FOO_BAR
m4 macros expand to shell code themselves.
Caveat: This will not check whether your compiler actually supports the -std=c11
flag. If you want to check for that, you can use use AX_CHECK_COMPILE_FLAG
from the autoconf archive:
AX_CHECK_COMPILE_FLAG([-std=c11], [
CFLAGS+=" -std=c11"
], [
echo "C compiler cannot compile C11 code"
exit -1
])
...although simply waiting until something fails in the compilation also works, I suppose. The error message will be nicer this way, though.