commit 147930b7672bd8efac0651e37b72962875d82e4d
parent 4c14df24c32aed73e90a7e5a7bbe3019739df0cb
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 8 Feb 2017 14:36:19 +0100
Fix CL compilation
Fix the compilation of the POSIX-based "open_output_stream" function. Fix minor
warnings.
Diffstat:
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/solstice.c b/src/solstice.c
@@ -23,14 +23,24 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include <errno.h>
#include <stdio.h>
-
-#ifdef OS_WINDOS
- /* TODO */
+#include <fcntl.h>
+
+#ifdef COMPILER_CL
+ /* Wrap POSIX functions and constants */
+ #include <io.h>
+ #define open _open
+ #define close _close
+ #define fdopen _fdopen
+ #define O_CREAT _O_CREAT
+ #define O_WRONLY _O_WRONLY
+ #define O_EXCL _O_EXCL
+ #define O_TRUNC _O_TRUNC
+ #define S_IRUSR _S_IREAD
+ #define S_IWUSR _S_IWRITE
#else
/* open/close functions */
- #include <errno.h>
- #include <fcntl.h>
#include <unistd.h>
#endif
@@ -398,7 +408,10 @@ open_output_stream(const char* name, const int force_overwriting)
if(!prompt_yes_no()) return NULL;
fd = open(name, O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IRUSR);
- if(fd >= 0 && !(fp = fdopen(fd, "w"))) goto error;
+ if(fd >= 0) {
+ fp = fdopen(fd, "w");
+ if(!fp) goto error;
+ }
}
}
diff --git a/src/test_solstice_args.c b/src/test_solstice_args.c
@@ -23,6 +23,11 @@
#include <string.h>
#include <limits.h>
+#ifdef COMPILER_CL
+ #pragma warning(push)
+ #pragma warning(disable:4706) /* Assignment within a condition */
+#endif
+
static char**
cmd_create(int dummy, ...)
{
@@ -49,6 +54,10 @@ cmd_create(int dummy, ...)
return cmd;
}
+#ifdef COMPILER_CL
+ #pragma warning(pop)
+#endif
+
static void
cmd_delete(char** cmd)
{