Make autotools add -std = c11 in CFLAGS

There is no analogue to indicate .AC_PROG_CC_C11AC_PROG_CC_C99

How can I get the autotools project to put --std=c11in CFLAGS?

+5
source share
2 answers

The easiest way is by setting

CFLAGS+=" -std=c11"

in yours configure.ac(in addition to AC_PROG_CC). configure.acis a template for a shell script, so you can simply paste shell code into it. In fact, all AC_FOO_BARm4 macros expand to the shell code itself.

Warning. This does not check if your compiler supports the flag -std=c11. If you want to verify this, you can use autoconfAX_CHECK_COMPILE_FLAG from the archive :

AX_CHECK_COMPILE_FLAG([-std=c11], [
  CFLAGS+=" -std=c11"
], [
  echo "C compiler cannot compile C11 code"
  exit -1
])

... , - , , . .

+6
AC_DEFUN([AX_CHECK_STDC],
[AX_CHECK_COMPILE_FLAG([-std=gnu11],
    [AX_APPEND_FLAG([-std=gnu11])],
    [AX_CHECK_COMPILE_FLAG([-std=c11],
        [AX_APPEND_FLAG([-std=c11])],
        [AX_CHECK_COMPILE_FLAG([-std=c99],
            [AX_APPEND_FLAG([-std=c99])],
            [AC_MSG_ERROR([C compiled does not support at least C99!])])
        ])
    ])
])

:

checking whether C compiler accepts -std=gnu11... no
checking whether C compiler accepts -std=c11... no
checking whether C compiler accepts -std=c99... yes

( PIC- shit Microchip xc16)

0

All Articles