chrisdew chrisdew - 6 months ago 72
C Question

Make autotools add --std=c11 to CFLAGS

There is no mention of a

analogue to

How can I get my autotools project to put


Most simply by putting

CFLAGS+=" -std=c11"

into your (in addition to AC_PROG_CC). 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:

  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.