I have a few functions sharing common arguments I want to pass across, so is it possible to use a macro to save me from repeatedly writing out the common arguments?
As an example, would the following work?
#define STD_ARGS arg1, int arg2, int arg3
foo(int STD_ARGS, int foo_arg1, int foo_arg2);
foo(int STD_ARGS, int foo_arg1, int foo_arg2) {
...
}
Sure, that’s legal. Expansion of
#define-d macros is nothing but a replacement of tokens, ignoring what (if anything) those tokens mean.(Whether this is a good idea or not depends on how well it’s documented, how far the usage spreads, and things like that.)