]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - gmqcc.h
ast_binary takes 2 expressions, not 2 values, ast_store takes a value and and express...
[xonotic/gmqcc.git] / gmqcc.h
diff --git a/gmqcc.h b/gmqcc.h
index 764ac52cddae7a7fdc1c275bc667a4d9e730d7ed..6da465b42e741533fb18ce58509c16ef75114582 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
 #else
 #   define GMQCC_WARN
 #endif
+/*
+ * This is a hack to silent clang regarding empty
+ * body if statements.
+ */
+#define GMQCC_SUPRESS_EMPTY_BODY do { } while (0)
 
 /*
  * stdint.h and inttypes.h -less subset
@@ -228,6 +233,8 @@ uint32_t util_crc32(const char *, int, register const short);
 #endif
 
 /* Builds vector type (usefull for inside structures) */
+#define VECTOR_SNAP(X,Y) X ## Y
+#define VECTOR_FILL(X,Y) VECTOR_SNAP(X,Y)
 #define VECTOR_TYPE(T,N)                                        \
     T*     N##_data      = NULL;                                \
     long   N##_elements  = 0;                                   \
@@ -258,7 +265,8 @@ uint32_t util_crc32(const char *, int, register const short);
         elements--;                                             \
         while (N##_add(*++elements) != -1 && len--);            \
         return N##_elements;                                    \
-    }
+    }                                                           \
+    typedef char VECTOR_FILL(extra_semicolon_,__COUNTER__)
 /* Builds a full vector inspot */
 #define VECTOR_MAKE(T,N) \
     VECTOR_TYPE(T,N);    \
@@ -304,17 +312,17 @@ typedef struct {
     union {
         int16_t  s1; /* signed   */
         uint16_t u1; /* unsigned */
-    };
+    } o1;
     /* operand 2 */
     union {
         int16_t  s2; /* signed   */
         uint16_t u2; /* unsigned */
-    };
+    } o2;
     /* operand 3 */
     union {
         int16_t  s3; /* signed   */
         uint16_t u3; /* unsigned */
-    };
+    } o3;
     
     /*
      * This is the same as the structure in darkplaces
@@ -573,12 +581,12 @@ extern int  opts_compiler;
 //======================================================================
 #define MEM_VECTOR_PROTO(Towner, Tmem, mem)                   \
     bool GMQCC_WARN Towner##_##mem##_add(Towner*, Tmem);      \
-    bool GMQCC_WARN Towner##_##mem##_remove(Towner*, size_t);
+    bool GMQCC_WARN Towner##_##mem##_remove(Towner*, size_t)
 
 #define MEM_VECTOR_PROTO_ALL(Towner, Tmem, mem)                    \
-    MEM_VECTOR_PROTO(Towner, Tmem, mem)                            \
+    MEM_VECTOR_PROTO(Towner, Tmem, mem);                           \
     bool GMQCC_WARN Towner##_##mem##_find(Towner*, Tmem, size_t*); \
-    void Towner##_##mem##_clear(Towner*);
+    void Towner##_##mem##_clear(Towner*)
 
 #define MEM_VECTOR_MAKE(Twhat, name) \
     Twhat  *name;                    \
@@ -652,17 +660,17 @@ void Tself##_##mem##_clear(Tself *self) \
 {                                       \
     if (!self->mem)                     \
         return;                         \
-    free((void*) self->mem);            \
+    mem_d((void*) self->mem);           \
     self->mem = NULL;                   \
     self->mem##_count = 0;              \
     self->mem##_alloc = 0;              \
 }
 
-#define MEM_VECTOR_CLEAR(owner, mem) \
-    if ((owner)->mem)                \
-        free((void*)((owner)->mem)); \
-    (owner)->mem = NULL;             \
-    (owner)->mem##_count = 0;        \
+#define MEM_VECTOR_CLEAR(owner, mem)  \
+    if ((owner)->mem)                 \
+        mem_d((void*)((owner)->mem)); \
+    (owner)->mem = NULL;              \
+    (owner)->mem##_count = 0;         \
     (owner)->mem##_alloc = 0
 
 #define MEM_VECTOR_INIT(owner, mem) \
@@ -695,8 +703,8 @@ typedef struct {
  * A shallow copy of a lex_file to remember where which ast node
  * came from.
  */
-typedef struct lex_ctx {
+typedef struct {
     const char *file;
-    size_t     line;
+    size_t      line;
 } lex_ctx;
 #endif