SOLVED, I found a solution to declare variable through macro and macro syntax,
the declare.c is generate by other tools, so I can't modify it.
[I_VAR.c]
#define _DECLARE_VAR_I TYPE NAME;
#define _DECLARE_VAR_U
#define DECLARE_VAR(TYPE, NAME, CLASS) \
_DECLARE_VAR_##CLASS(TYPE, NAME)
#include "declare.h"
#undef _DECLARE_VAR_I
#undef _DECLARE_VAR_U
[U_VAR.c]
#define _DECLARE_VAR_I
#define _DECLARE_VAR_U TYPE NAME;
#define DECLARE_VAR(TYPE, NAME, CLASS) \
_DECLARE_VAR_##CLASS(TYPE, NAME)
#include "declare.h"
#undef _DECLARE_VAR_I
#undef _DECLARE_VAR_U
I have a macro to declare global variable, and the macro has a syntax call "class" for separate those declaration to different C file, but the preprocessor show me an error, because I use "ifdef" in macro.
does any idea? thanks!
(1)macro
#define DECLARE_VAR(TYPE, NAME, CLASS) \
#ifdef CLASS \
TYPE NAME; \
#endif
(2) [declare.h] generate by tools
DECLARE_VAR(int, i0, I)
DECLARE_VAR(int, i1, I)
DECLARE_VAR(int, i2, I)
DECLARE_VAR(int, u0, U)
DECLARE_VAR(int, u1, U)
DECLARE_VAR(int, u2, U)
(3) [I_Var.c]
#define I
#include "declare.h"
[U_Var.c]
#define U
#include "declare.h"
it's possble to separate variable to different file through macro parameter?