Hello. I'm having a slight problem. I am writing a command editor and I was thinking to simplify the command name/do_function table by making interp.h serve two purposes.
#ifdef DECLARE_DO_FUN
#undef DECLARE_DO_FUN
#endif
#define DECLARE_DO_FUN(do_fun) ( {(char) do_fun, do_fun}, )
const struct cmdfun_type cmdfun_table [] =
{
#include "interp.h"
{"NULL",NULL}
};
#undef DECLARE_DO_FUN
#define DECLARE_DO_FUN(do_fun) void do_fun();
The basic idea is that it will load interp.h converting all the DECLARE_DO_FUN() statements into both a string for the function name ("do_advance") and the function name itself (do_advance). I keep getting this error, however:
interp.h:33: braced-group within expression allowed only inside a function
interp.h:33: `do_advance' undeclared here (not in a function)
interp.h:33: initializer element is not constant
interp.h:33: (near initialization for `cmdfun_table[0]')
interp.h:33: syntax error before ')' token
Any suggestions? I think the error is in my typecasting statement. I can't seem to find a good tip on the subject on the net, however.
#ifdef DECLARE_DO_FUN
#undef DECLARE_DO_FUN
#endif
#define DECLARE_DO_FUN(do_fun) ( {(char) do_fun, do_fun}, )
const struct cmdfun_type cmdfun_table [] =
{
#include "interp.h"
{"NULL",NULL}
};
#undef DECLARE_DO_FUN
#define DECLARE_DO_FUN(do_fun) void do_fun();
The basic idea is that it will load interp.h converting all the DECLARE_DO_FUN() statements into both a string for the function name ("do_advance") and the function name itself (do_advance). I keep getting this error, however:
interp.h:33: braced-group within expression allowed only inside a function
interp.h:33: `do_advance' undeclared here (not in a function)
interp.h:33: initializer element is not constant
interp.h:33: (near initialization for `cmdfun_table[0]')
interp.h:33: syntax error before ')' token
Any suggestions? I think the error is in my typecasting statement. I can't seem to find a good tip on the subject on the net, however.