From ffb8595440a35ab769f17a6c3af00df5063a5239 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Sun, 7 Apr 2013 22:19:23 +0200
Subject: [PATCH] Allow for warning-free build of common with MS VC on warning
level 3.
---
src/common/fp.c | 4 ++--
src/common/inttypes.h | 8 ++++----
src/common/searchpath.c | 1 +
src/common/va_copy.h | 5 +++++
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/common/fp.c b/src/common/fp.c
index c9300c52d..d2c5f5218 100644
--- a/src/common/fp.c
+++ b/src/common/fp.c
@@ -99,7 +99,7 @@ Float FP_F_FromInt (long Val)
/* Convert an integer into a floating point variable */
{
Float D;
- D.V = Val;
+ D.V = (float) Val;
return D;
}
@@ -164,7 +164,7 @@ size_t FP_D_Size (void)
unsigned char* FP_D_Data (Double Val)
/* Return the raw data of a double in a malloc'ed buffer. Free after use. */
{
- float F = Val.V;
+ float F = (float) Val.V;
return memcpy (xmalloc (F_SIZE), &F, F_SIZE);
}
diff --git a/src/common/inttypes.h b/src/common/inttypes.h
index ca7f90106..3c87eb7be 100644
--- a/src/common/inttypes.h
+++ b/src/common/inttypes.h
@@ -39,11 +39,11 @@
/* If we have stdint.h, include it, otherwise try some quesswork on types.
- * gcc doesn't define __STDC_VERSION__ without special flags, so check for
- * gcc explicitly. Undefined symbols are replaced by zero, so a check for
- * defined(__GNUC__) is not necessary.
+ * gcc and msvc don't define __STDC_VERSION__ without special flags, so check
+ * for them explicitly. Undefined symbols are replaced by zero, so a check for
+ * defined(__GNUC__) or defined(_MSC_VER) is not necessary.
*/
-#if (__STDC_VERSION__ >= 199901) || (__GNUC__ >= 3)
+#if (__STDC_VERSION__ >= 199901) || (__GNUC__ >= 3) || (_MSC_VER >= 1600)
#include
#else
diff --git a/src/common/searchpath.c b/src/common/searchpath.c
index 217502299..78d2cce4c 100644
--- a/src/common/searchpath.c
+++ b/src/common/searchpath.c
@@ -38,6 +38,7 @@
#if defined(_MSC_VER)
/* Microsoft compiler */
# include
+# pragma warning(disable : 4996)
#else
/* Anyone else */
# include
diff --git a/src/common/va_copy.h b/src/common/va_copy.h
index cb896b477..30f275461 100644
--- a/src/common/va_copy.h
+++ b/src/common/va_copy.h
@@ -57,6 +57,11 @@
#define va_copy(dest,src) __va_copy(dest, src)
#endif
+/* MS VC allows for assignment */
+#if defined(_MSC_VER)
+#define va_copy(dest,src) ((dest) = (src))
+#endif
+
/* If va_copy is not defined now, we have a problem */
#if !defined(va_copy)
#error "Need a working va_copy!"
--
2.39.5