summaryrefslogtreecommitdiffstats
path: root/src/configure.ac
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-04-19 20:39:41 +0200
committerBram Moolenaar <Bram@vim.org>2018-04-19 20:39:41 +0200
commit226400830b470774bf5a552e1af10706b609720c (patch)
tree0e3839bcc0e2399e1f88ad9ad931cd929303962b /src/configure.ac
parent285e3358696b1bc6296e5d4c53425680ce8fbd54 (diff)
patch 8.0.1736: check for C99 features is incompletev8.0.1736
Problem: Check for C99 features is incomplete. Solution: Use AC_PROG_CC_C99 and when C99 isn't fully supported check the features we need. (James McCoy, closes #2820)
Diffstat (limited to 'src/configure.ac')
-rw-r--r--src/configure.ac50
1 files changed, 32 insertions, 18 deletions
diff --git a/src/configure.ac b/src/configure.ac
index 78023ad226..7f55281839 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -11,7 +11,7 @@ AC_DEFINE(UNIX)
AC_PROG_MAKE_SET
dnl Checks for programs.
-AC_PROG_CC_C89 dnl required by almost everything
+AC_PROG_CC_C99 dnl required by almost everything
AC_PROG_CPP dnl required by header file checks
AC_PROGRAM_EGREP dnl required by AC_EGREP_CPP
AC_PROG_FGREP dnl finds working grep -F
@@ -30,23 +30,37 @@ AC_HEADER_STDC
AC_HEADER_SYS_WAIT
dnl Check that the C99 features that Vim uses are supported:
-dnl - // commands
-dnl - comma after last enum item
-dnl - "long long int" and "long long unsigned"
-dnl - flexible array member
-AC_MSG_CHECKING(if the compiler can handle Vim code)
-AC_TRY_COMPILE([#include <stdio.h>], [
- enum {
- one, // one comment
- two, // two comments
- three, // three comments
- };
- long long int a = 1;
- long long unsigned b = 2;
- printf("a %lld and a %llu", a, b);
- ],
-AC_MSG_RESULT(yes),
-AC_MSG_ERROR([compiler does not work properly - see auto/config.log]))
+if test x"$ac_cv_prog_cc_c99" != xno; then
+ dnl If the compiler doesn't explicitly support C99, then check
+ dnl for the specific features Vim uses
+
+ AC_TYPE_LONG_LONG_INT
+ if test "$ac_cv_type_long_long_int" = no; then
+ AC_MSG_FAILURE([Compiler does not support long long int])
+ fi
+
+ AC_MSG_CHECKING([if the compiler supports trailing commas])
+ trailing_commas=no
+ AC_TRY_COMPILE([], [
+ enum {
+ one,
+ };],
+ [AC_MSG_RESULT(yes); trailing_commas=yes],
+ [AC_MSG_RESULT(no)])
+ if test "$trailing_commas" = no; then
+ AC_MSG_FAILURE([Compiler does not support trailing comma in enum])
+ fi
+
+ AC_MSG_CHECKING([if the compiler supports C++ comments])
+ slash_comments=no
+ AC_TRY_COMPILE([],
+ [// C++ comments?],
+ [AC_MSG_RESULT(yes); slash_comments=yes],
+ [AC_MSG_RESULT(no)])
+ if test "$slash_comments" = no; then
+ AC_MSG_FAILURE([Compiler does not support C++ comments])
+ fi
+fi
dnl Check for the flag that fails if stuff are missing.