/*
* This file is part of DisOrder
- * Copyright (C) 2004, 2005 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#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
*/