Main. C: 51:46: error: macro "my_print requires 5" the arguments, but only 2 given
Voss_print (COMM_INFO, "test print \ n");
# define SUBSYS_NO 1
# define MDLNO_COMM 1
# define PRINT_INFO 1
# define COMM_INFO SUBSYS_NO MDLNO_COMM, PRINT_INFO
# define the_print printf
# define my_print (subsystem, module, level, format,... ) the_print (format, # # __VA_ARGS__)
My_print (1, 1, 1, "test print \ n");
My_print (1, 1, 1, "test print % d \ n", 1);
/* this a compiler error, macro expansion after the compiler thinks parameter number not enough */
My_print (COMM_INFO, "test print \ n");
CodePudding user response:
You are using the macro function is nested inside the macro rare writing you can directly precompiled in C and see what is aThis code error occurs at compile time rather than pretreatment period under Linux easily by GCC view pretreatment may be inconsistent and you want,
CodePudding user response:
Int main ()
{
Printf (" test print \ n ");
Printf (" test print \ n ");
The printf ();
return 0;
}
After preprocessing. I file code is empty after you macro substitution
CodePudding user response:
# define COMM_INFO SUBSYS_NO MDLNO_COMM, PRINT_INFO
The macro definition has a problem, it is suggested that see COMM_INFO content, COMM_INFO corresponding SUBSYS_NO