[m-rev.] for review: support MS VC 2015

Sebastian Godelet sebastian.godelet at outlook.com
Tue Mar 1 23:27:02 AEDT 2016


Support compiling Mercury with MS Visual C compiler 2015, which currently fails configuring.
This is due to the added support of the ISO C99 (v)snprintf function family which then fails the functional test.
Instead of issuing a warning in the AC_CHECK_FUNC test, `cl' exists with #error, thus failing the test.
So similar to other solutions of this common the configure script checks for the valid declaration in stdio.h instead.

Configure.ac:
    Introduce mercury_check_for_stdio_functions and check for declaration of the (v)snprintf functions.

Sebastian.

diff --git a/configure.ac b/configure.ac
index 0ead768..8739b7d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1275,6 +1275,17 @@ mercury_check_for_functions () {
     done
 }
 
+mercury_check_for_stdio_functions () {
+    for mercury_cv_stdio_func in "$@"
+    do
+        mercury_cv_stdio_func_define="MR_HAVE_`echo $mercury_cv_stdio_func | \
+            tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`"
+        AC_CHECK_DECL($mercury_cv_stdio_func, [
+            AC_DEFINE_UNQUOTED($mercury_cv_stdio_func_define)
+        ], , [#include <stdio.h>])
+    done
+}
+
 # Don't try to use mprotect() on gnu-win32, since it is broken
 # (at least for version b18, anyway) and trying it can crash Win95.
 case "$host" in
@@ -1299,7 +1310,6 @@ mercury_check_for_functions \
         sysconf getpagesize gethostname \
         mmap mprotect memalign posix_memalign sbrk memmove \
         sigaction siginterrupt setitimer \
-        snprintf _snprintf vsnprintf _vsnprintf \
         strerror strerror_r strerror_s \
         open close dup dup2 fdopen fileno fstat stat lstat isatty \
         getpid setpgid fork execlp wait kill \
@@ -1309,6 +1319,9 @@ mercury_check_for_functions \
         sched_getaffinity sched_getcpu sched_yield mkstemp setrlimit \
         fma
 
+mercury_check_for_stdio_functions \
+        snprintf _snprintf vsnprintf _vsnprintf
+
 #-----------------------------------------------------------------------------#
 
 MERCURY_CHECK_FOR_HEADERS( \




More information about the reviews mailing list