diff --git a/include/QF/progs/pr_comp.h b/include/QF/progs/pr_comp.h index 98de7cae0..88a644f62 100644 --- a/include/QF/progs/pr_comp.h +++ b/include/QF/progs/pr_comp.h @@ -62,6 +62,9 @@ typedef enum { ev_type_count // not a type, gives number of types } etype_t; +#define PR_SIZEOF(type) (sizeof (pr_##type##_t) / sizeof (pr_int_t)) +#define PR_ALIGNOF(type) (__alignof__ (pr_##type##_t) / __alignof__ (pr_int_t)) + extern const pr_ushort_t pr_type_size[ev_type_count]; extern const pr_ushort_t pr_type_alignment[ev_type_count]; extern const char * const pr_type_name[ev_type_count]; diff --git a/libs/gamecode/pr_opcode.c b/libs/gamecode/pr_opcode.c index 289f06a1f..34a36c242 100644 --- a/libs/gamecode/pr_opcode.c +++ b/libs/gamecode/pr_opcode.c @@ -33,13 +33,13 @@ #include "QF/progs.h" -#define EV_TYPE(type) (sizeof (pr_##type##_t) / sizeof (pr_int_t)), +#define EV_TYPE(type) PR_SIZEOF(type), VISIBLE const pr_ushort_t pr_type_size[ev_type_count] = { #include "QF/progs/pr_type_names.h" 0, // ev_invalid not a valid/simple type }; -#define EV_TYPE(type) (__alignof__ (pr_##type##_t) / __alignof__ (pr_int_t)), +#define EV_TYPE(type) PR_ALIGNOF(type), VISIBLE const pr_ushort_t pr_type_alignment[ev_type_count] = { #include "QF/progs/pr_type_names.h" 0, // ev_invalid not a valid/simple type diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index a52594af8..ceb0360a5 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -64,7 +64,7 @@ type_t type_##t = { \ .type = ev_##t, \ .name = #t, \ - .alignment = __alignof__(pr_##t##_t) / __alignof__ (pr_int_t), \ + .alignment = PR_ALIGNOF(t), \ .meta = ty_basic, \ {{ __builtin_choose_expr (ev_##t == ev_field \ || ev_##t == ev_func \