|
楼主 |
发表于 2009-6-17 11:11:07
|
显示全部楼层
#include <assert.h>
typedef void (*MENUHANDLER)(void);
#define MAX_MENU_COUNT 10
MENUHANDLER p[MAX_MENU_COUNT];
#define ADD_MENUITEM_HANDLER(D,F) assert(##D < 10); p[##D] = ##F;
#define ADD_HANDLER(_M_) ADD_MENUITEM_HANDLER(MAIN_MENU_##_M_##_MENUID, highlight_mainmenu_##_M_);
enum
{
MAIN_MENU_AUDIO_PLAYER_MENUID = 9,
MAIN_MENU_CAMERA_MENUID,
MAIN_MENU_MAX_MENUID
};
void highlight_mainmenu_AUDIO_PLAYER(void)
{
}
void highlight_mainmenu_CAMERA(void)
{
}
int main(int argc, char* argv[])
{
MENUHANDLER f;
ADD_HANDLER(CAMERA);
f = p[MAIN_MENU_CAMERA_MENUID];
return 0;
} |
|