Commit 06398a22d0

Andrew Kelley <superjoe30@gmail.com>
2016-02-17 04:34:45
back to normal print specifiers
disable warnings for format specifiers on mingw since the compiler emits bogus warnings
1 parent bb806f9
src/analyze.cpp
@@ -396,7 +396,7 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t
         entry->zero_bits = (array_size == 0) || child_type->zero_bits;
 
         buf_resize(&entry->name, 0);
-        buf_appendf(&entry->name, "[%" PRIuMAX "]%s", (uintmax_t)array_size, buf_ptr(&child_type->name));
+        buf_appendf(&entry->name, "[%" PRIu64 "]%s", array_size, buf_ptr(&child_type->name));
 
         if (!entry->zero_bits) {
             uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, entry->type_ref);
@@ -4158,9 +4158,9 @@ static TypeTableEntry *analyze_builtin_fn_call_expr(CodeGen *g, ImportTableEntry
                     uint64_t src_align = get_memcpy_align(g, src_type->data.pointer.child_type);
                     if (dest_align != src_align) {
                         add_node_error(g, dest_node, buf_sprintf(
-                            "misaligned memcpy, '%s' has alignment '%" PRIuMAX ", '%s' has alignment %" PRIuMAX,
-                                    buf_ptr(&dest_type->name), (uintmax_t)dest_align,
-                                    buf_ptr(&src_type->name), (uintmax_t)src_align));
+                            "misaligned memcpy, '%s' has alignment '%" PRIu64 ", '%s' has alignment %" PRIu64,
+                                    buf_ptr(&dest_type->name), dest_align,
+                                    buf_ptr(&src_type->name), src_align));
                     }
                 }
 
src/ast_render.cpp
@@ -351,7 +351,7 @@ void ast_print(FILE *f, AstNode *node, int indent) {
                 NumLit kind = node->data.number_literal.kind;
                 const char *name = node_type_str(node->type);
                 if (kind == NumLitUInt) {
-                    fprintf(f, "%s uint %" PRIuMAX "\n", name, (uintmax_t)node->data.number_literal.data.x_uint);
+                    fprintf(f, "%s uint %" PRIu64 "\n", name, node->data.number_literal.data.x_uint);
                 } else {
                     fprintf(f, "%s float %f\n", name, node->data.number_literal.data.x_float);
                 }
@@ -679,7 +679,7 @@ static void render_node(AstRender *ar, AstNode *node) {
         case NodeTypeNumberLiteral:
             switch (node->data.number_literal.kind) {
                 case NumLitUInt:
-                    fprintf(ar->f, "%" PRIuMAX, (uintmax_t)node->data.number_literal.data.x_uint);
+                    fprintf(ar->f, "%" PRIu64, node->data.number_literal.data.x_uint);
                     break;
                 case NumLitFloat:
                     fprintf(ar->f, "%f", node->data.number_literal.data.x_float);
src/bignum.cpp
@@ -265,8 +265,7 @@ Buf *bignum_to_buf(BigNum *bn) {
         return buf_sprintf("%f", bn->data.x_float);
     } else {
         const char *neg = bn->is_negative ? "-" : "";
-        uintmax_t value = bn->data.x_uint;
-        return buf_sprintf("%s%" PRIuMAX, neg, value);
+        return buf_sprintf("%s%llu", neg, bn->data.x_uint);
     }
 }
 
CMakeLists.txt
@@ -181,7 +181,12 @@ include_directories(
 
 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -Wall")
 
-set(EXE_CFLAGS "-std=c++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes")
+
+if(MINGW)
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-error=format= -Wno-error=format -Wno-error=format-extra-args")
+endif()
+
+set(EXE_CFLAGS "-std=c++11 -fno-exceptions -fno-rtti -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__USE_MINGW_ANSI_STDIO -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes")
 
 add_executable(zig ${ZIG_SOURCES})
 set_target_properties(zig PROPERTIES