chrisdew chrisdew - 1 year ago 205
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download