- %zu is not supported on windows
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 16 Nov 2008 22:35:01 +0000 (22:35 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 16 Nov 2008 22:35:01 +0000 (22:35 +0000)
- kicked some obstack_printf()

[r23714]

ast2firm.c
config.h.in
mangle.c
parser.c

index 0d8f1eb..6d1c466 100644 (file)
@@ -3287,7 +3287,7 @@ static __attribute__((unused)) void debug_print_type_path(const type_path_t *pat
                if (is_type_compound(type)) {
                        fprintf(stderr, ".%s", entry->compound_entry->base.symbol->string);
                } else if (is_type_array(type)) {
-                       fprintf(stderr, "[%zu]", entry->index);
+                       fprintf(stderr, "[" SIZET_FMT "]", entry->index);
                } else {
                        fprintf(stderr, "-INVALID-");
                }
index 36ee491..523798e 100644 (file)
@@ -17,3 +17,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
+#ifdef _WIN32
+/* default windows runtime does not support %zu */
+#define SIZET_FMT  "%u"
+#else
+#define SIZET_FMT  "%zu"
+#endif
index a79d4e1..6822b84 100644 (file)
--- a/mangle.c
+++ b/mangle.c
@@ -108,7 +108,7 @@ static void mangle_class_enum_type(const entity_base_t *ent)
        const symbol_t *sym = ent->symbol;
        if (sym != NULL) {
                const char *name = sym->string;
-               obstack_printf(&obst, "%zu%s", strlen(name), name);
+               obstack_printf(&obst, SIZET_FMT "%s", strlen(name), name);
        } else {
                /* TODO need the first typedef name here */
                panic("mangling of unnamed class/enum types not implemented yet");
@@ -118,23 +118,26 @@ static void mangle_class_enum_type(const entity_base_t *ent)
 static void mangle_array_type(const array_type_t *type)
 {
        if (type->is_vla) {
-               obstack_printf(&obst, "A_");
+               obstack_1grow(&obst, 'A');
+               obstack_1grow(&obst, '_');
        } else if (type->size_constant) {
-               obstack_printf(&obst, "A%zu_", type->size);
+               obstack_printf(&obst, "A" SIZET_FMT "_", type->size);
        } else {
-               panic("mangling of non-constant sized arrray types not implemented yet");
+               panic("mangling of non-constant sized array types not implemented yet");
        }
        mangle_type(type->element_type);
 }
 
 static void mangle_complex_type(const complex_type_t *type)
 {
-       obstack_printf(&obst, "C%c", get_atomic_type_mangle(type->akind));
+       obstack_1grow(&obst, 'C');
+       obstack_1grow(&obst, get_atomic_type_mangle(type->akind));
 }
 
 static void mangle_imaginary_type(const imaginary_type_t *type)
 {
-       obstack_printf(&obst, "G%c", get_atomic_type_mangle(type->akind));
+       obstack_1grow(&obst, 'G');
+       obstack_1grow(&obst, get_atomic_type_mangle(type->akind));
 }
 
 static void mangle_qualifiers(type_qualifiers_t qualifiers)
@@ -205,7 +208,7 @@ static void mangle_entity(entity_t *entity)
        /* TODO: mangle scope */
 
        const char *name = entity->base.symbol->string;
-       obstack_printf(&obst, "%zu%s", strlen(name), name);
+       obstack_printf(&obst, SIZET_FMT "%s", strlen(name), name);
 
        if (entity->kind == ENTITY_FUNCTION) {
                mangle_parameters(&entity->declaration.type->function);
@@ -271,12 +274,12 @@ ident *create_name_win32(entity_t *entity)
 
                        case CC_STDCALL:
                        case CC_FASTCALL: {
-                               ir_type *irtype = get_ir_type(entity->declaration.type);
-                               size_t   size   = 0;
+                               ir_type  *irtype = get_ir_type(entity->declaration.type);
+                               unsigned size    = 0;
                                for (int i = get_method_n_params(irtype) - 1; i >= 0; --i) {
                                        size += get_type_size_bytes(get_method_param_type(irtype, i));
                                }
-                               obstack_printf(o, "@%zu", size);
+                               obstack_printf(o, "@%u", size);
                                break;
                        }
 
index 39e0e88..ea832ca 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2358,7 +2358,7 @@ static __attribute__((unused)) void debug_print_type_path(
                        fprintf(stderr, ".%s",
                                entry->v.compound_entry->base.symbol->string);
                } else if (is_type_array(type)) {
-                       fprintf(stderr, "[%zu]", entry->v.index);
+                       fprintf(stderr, "[" SIZET_FMT "]", entry->v.index);
                } else {
                        fprintf(stderr, "-INVALID-");
                }