X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/460b9539a7c15580e41a71bbc0f47ae776238915..d8b957853160200fe6b00d8c0e8c61a3f62ecd7c:/lib/table.h diff --git a/lib/table.h b/lib/table.h index 476399d..a301db7 100644 --- a/lib/table.h +++ b/lib/table.h @@ -1,6 +1,6 @@ /* * 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 @@ -21,13 +21,15 @@ #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 + +#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 */ @@ -43,4 +45,3 @@ c-basic-offset:2 comment-column:40 End: */ -/* arch-tag:15b07f98a592f80e4e22dd3f213f2580 */