1 ## ----------------------------------------- ##
2 ## ANSIfy the C compiler whenever possible. ##
3 ## From Franc,ois Pinard ##
4 ## ----------------------------------------- ##
8 # @defmac AC_PROG_CC_STDC
9 # @maindex PROG_CC_STDC
11 # If the C compiler in not in ANSI C mode by default, try to add an option
12 # to output variable @code{CC} to make it so. This macro tries various
13 # options that select ANSI C on some system or another. It considers the
14 # compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
15 # handles function prototypes correctly.
17 # If you use this macro, you should check after calling it whether the C
18 # compiler has been set to accept ANSI C; if not, the shell variable
19 # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
20 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
21 # program @code{ansi2knr}, which comes with Ghostscript.
24 AC_DEFUN(AM_PROG_CC_STDC,
25 [AC_REQUIRE([AC_PROG_CC])
26 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
27 AC_CACHE_VAL(am_cv_prog_cc_stdc,
28 [am_cv_prog_cc_stdc=no
30 # Don't try gcc -ansi; that turns off useful extensions and
31 # breaks some systems' header files.
33 # Ultrix and OSF/1 -std1
34 # HP-UX -Aa -D_HPUX_SOURCE
35 # SVR4 -Xc -D__EXTENSIONS__
36 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
38 CC="$ac_save_CC $ac_arg"
40 [#if !defined(__STDC__) || __STDC__ != 1
43 /* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
45 # include <sys/types.h>
46 # include <sys/stat.h>
49 int test (int i, double x);
50 struct s1 {int (*f) (int a);};
51 struct s2 {int (*f) (double a);};],
52 [am_cv_prog_cc_stdc="$ac_arg"; break])
56 AC_MSG_RESULT($am_cv_prog_cc_stdc)
57 case "x$am_cv_prog_cc_stdc" in
59 *) CC="$CC $am_cv_prog_cc_stdc" ;;