Where to add a CFLAG, such as -std=gnu99, into an autotools project

后端 未结 3 1752
再見小時候
再見小時候 2020-12-25 12:09

I have a simple Autotools C project (not C++).

CFLAGs (by inspection) seem to be -g -O2.

I want all of the generated make files to also have

3条回答
  •  一生所求
    2020-12-25 13:04

    autoconf has a macro for this:

    Just put:

    AC_PROG_CC_STDC
    

    after your AC_PROG_CC and everything will be right.

    Especially when you use other compilers that do not have -std=gnu99 but operate in C99 mode by default (or have a different option hpcc's -AC99 springs to mind).

    I would NOT use CFLAGS for that kind of thing.

    From the docs:

    -- Macro: AC_PROG_CC_STDC
    If the C compiler cannot compile ISO Standard C (currently C99),
    try to add an option to output variable `CC' to make it work.  If
    the compiler does not support C99, fall back to supporting ANSI
    C89 (ISO C90).
    
    After calling this macro you can check whether the C compiler has
    been set to accept Standard C; if not, the shell variable
    `ac_cv_prog_cc_stdc' is set to `no'.

提交回复
热议问题