[clinfo] 91/148: Initial support for Microsoft's C compiler

Andreas Beckmann anbe at moszumanska.debian.org
Mon Nov 17 14:09:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

anbe pushed a commit to branch clinfo
in repository clinfo.

commit 0ac33f4f5a768c3696e505c135e9bf2ccb5c5a3b
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date:   Mon Oct 27 21:09:31 2014 +0100

    Initial support for Microsoft's C compiler
---
 src/clinfo.c     |  5 +++++
 src/ms_support.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/src/clinfo.c b/src/clinfo.c
index b07be20..3929e8a 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -10,6 +10,11 @@
  */
 #include "fmtmacros.h"
 
+// Support for the horrible MS C compiler
+#ifdef _MSC_VER
+#include "ms_support.h"
+#endif
+
 #include "ext.h"
 #include "error.h"
 #include "memory.h"
diff --git a/src/ms_support.h b/src/ms_support.h
new file mode 100644
index 0000000..ea0ee56
--- /dev/null
+++ b/src/ms_support.h
@@ -0,0 +1,46 @@
+/* Missing functions and other misc stuff to support
+ * the horrible MS C compiler
+ *
+ * TODO could be improved by version-checking for C99 support
+ */
+
+// also disable strncpy vs strncpy_s warning
+#pragma warning(disable : 4996)
+
+// No inline in MS C
+#define inline __inline
+
+// No snprintf in MS C, copy over implementation taken from
+// stackoverflow
+
+#include <stdarg.h>
+
+inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
+{
+    int count = -1;
+
+    if (size != 0)
+        count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
+    if (count == -1)
+        count = _vscprintf(format, ap);
+
+    return count;
+}
+
+inline int c99_snprintf(char* str, size_t size, const char* format, ...)
+{
+    int count;
+    va_list ap;
+
+    va_start(ap, format);
+    count = c99_vsnprintf(str, size, format, ap);
+    va_end(ap);
+
+    return count;
+}
+
+#define snprintf c99_snprintf
+
+// And no __func__ either
+
+#define __func__ __FUNCTION__

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/clinfo.git



More information about the Pkg-opencl-commits mailing list