chiark / gitweb /
Source code reorganization:
[disorder] / lib / table.h
index 11215bb0bd0efd6f215fa4592cf68edce5d971a1..a301db70a1280af3faae84613b5574a7d9986e5b 100644 (file)
 #ifndef TABLE_H
 #define TABLE_H
 
-#define TABLE_FIND(TABLE, TYPE, FIELD, NAME)   \
-  table_find((void *)TABLE,                    \
-            offsetof(TYPE, FIELD),             \
-            sizeof (TYPE),                     \
-            sizeof TABLE / sizeof (TYPE),      \
+#include <stddef.h>
+
+#define TABLE_FIND(TABLE, FIELD, NAME)                 \
+  table_find((void *)TABLE,                            \
+            offsetof(typeof((TABLE)[0]), FIELD),       \
+            sizeof ((TABLE)[0]),                       \
+            sizeof TABLE / sizeof ((TABLE)[0]),        \
             NAME)
-/* Search TYPE TABLE[] for an element where TABLE[N].FIELD matches NAME
+/* Search TABLE[] for an element where TABLE[N].FIELD matches NAME
  * Returns the index N on success or -1 if not found
  * The table must be lexically sorted on FIELD
  */