Browse Source

Fix warnings

rexim 4 years ago
parent
commit
b69640cd3b
4 changed files with 22 additions and 11 deletions
  1. 12 2
      nobuild2.c
  2. 7 6
      nobuild2.h
  3. 2 2
      tools/hex.c
  4. 1 1
      tools/rot13.c

+ 12 - 2
nobuild2.c

@@ -1,12 +1,18 @@
 #define NOBUILD_IMPLEMENTATION
 #include "./nobuild2.h"
 
+#define CFLAGS "-Wall", "-Wextra", "-std=c11", "-pedantic"
+
 void build_tools(void)
 {
     FOREACH_FILE_IN_DIR(tool, "tools", {
         if (ENDS_WITH(tool, ".c")) {
             Cstr tool_path = PATH("tools", tool);
-            CMD("cc", "-o", NOEXT(tool_path), tool_path);
+#ifndef _WIN32
+            CMD("cc", CFLAGS, "-o", NOEXT(tool_path), tool_path);
+#else
+            CMD("cl.exe", "/Fe.\\tools\\", tool_path);
+#endif
         }
     });
 }
@@ -16,7 +22,11 @@ void run_examples(void)
     FOREACH_FILE_IN_DIR(example, "examples", {
         if (ENDS_WITH(example, ".c")) {
             Cstr example_path = PATH("examples", example);
-            CMD("cc", "-o", NOEXT(example_path), example_path);
+#ifndef _WIN32
+            CMD("cc", CFLAGS, "-o", NOEXT(example_path), example_path);
+#else
+            CMD("cl.exe", "/Fe.\\examples\\", example_path);
+#endif
             CMD(NOEXT(example_path));
         }
     });

+ 7 - 6
nobuild2.h

@@ -1,13 +1,8 @@
 #ifndef NOBUILD_H_
 #define NOBUILD_H_
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-
 #ifndef _WIN32
+#    define _POSIX_C_SOURCE 200809L
 #    include <sys/types.h>
 #    include <sys/wait.h>
 #    include <sys/stat.h>
@@ -22,6 +17,12 @@
      typedef HANDLE Pid;
 #endif  // _WIN32
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+
 typedef const char * Cstr;
 
 int cstr_ends_with(Cstr cstr, Cstr postfix);

+ 2 - 2
tools/hex.c

@@ -9,7 +9,7 @@
 
 uint8_t buffer[COLUMNS];
 
-int main(int argc, char *argv[])
+int main(void)
 {
     while (!feof(stdin)) {
         size_t n = fread(buffer, sizeof(buffer[0]), COLUMNS, stdin);
@@ -20,7 +20,7 @@ int main(int argc, char *argv[])
         }
 
         assert(n <= COLUMNS);
-        printf("%*s", PADDING + (COLUMNS - n) * 3, "");
+        printf("%*s", (int) (PADDING + (COLUMNS - n) * 3), "");
 
         fwrite(buffer, sizeof(buffer[0]), n, stdout);
         printf("\n");

+ 1 - 1
tools/rot13.c

@@ -12,7 +12,7 @@ char rot13(char x)
 
 char buffer[BUFFER_SIZE];
 
-int main(int argc, char *argv[])
+int main(void)
 {
     while (!feof(stdin)) {
         size_t n = fread(buffer, sizeof(buffer[0]), BUFFER_SIZE, stdin);