diff src/configure.ac @ 13728:603516b73349 v8.0.1736

patch 8.0.1736: check for C99 features is incomplete commit https://github.com/vim/vim/commit/226400830b470774bf5a552e1af10706b609720c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 19 20:39:41 2018 +0200 patch 8.0.1736: check for C99 features is incomplete 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)
author Christian Brabandt <cb@256bit.org>
date Thu, 19 Apr 2018 20:45:06 +0200
parents d35b1702a1da
children 9ae15cd46d84
line wrap: on
line diff
--- 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.