lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Good evening

On lua.h there are some defines for integral constants that maybe can be converted to enum. Example where it is suggested https://clang.llvm.org/extra/clang-tidy/checks/modernize/macro-to-enum.html
Since enum is a language feature and not a preprocessor directive, it can be easier to debug or create static checks on switches.

For example:

/*
** Event codes
*/
#define LUA_HOOKCALL 0
#define LUA_HOOKRET 1
#define LUA_HOOKLINE 2
#define LUA_HOOKCOUNT 3
#define LUA_HOOKTAILCALL 4

after:
/*
** Event codes
*/
enum {
LUA_HOOKCALL = 0,
LUA_HOOKRET = 1,
LUA_HOOKLINE = 2,
LUA_HOOKCOUNT = 3,
LUA_HOOKTAILCALL = 4
};