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_BEFORE([$0], [AC_C_INLINE])
27 AC_BEFORE([$0], [AC_C_CONST])
28 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
29 AC_CACHE_VAL(am_cv_prog_cc_stdc,
30 [am_cv_prog_cc_stdc=no
32 # Don't try gcc -ansi; that turns off useful extensions and
33 # breaks some systems' header files.
35 # Ultrix and OSF/1 -std1
36 # HP-UX -Aa -D_HPUX_SOURCE
37 # SVR4 -Xc -D__EXTENSIONS__
38 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
40 CC="$ac_save_CC $ac_arg"
42 [#if !defined(__STDC__) || __STDC__ != 1
45 /* DYNIX/ptx V4.1.3 can't compile sys/stat.h with -Xc -D__EXTENSIONS__. */
47 # include <sys/types.h>
48 # include <sys/stat.h>
51 int test (int i, double x);
52 struct s1 {int (*f) (int a);};
53 struct s2 {int (*f) (double a);};],
54 [am_cv_prog_cc_stdc="$ac_arg"; break])
58 AC_MSG_RESULT($am_cv_prog_cc_stdc)
59 case "x$am_cv_prog_cc_stdc" in
61 *) CC="$CC $am_cv_prog_cc_stdc" ;;