このマクロを考えると:
#define SOME_MACRO(ret, f, args) \
typedef ret (*some_func_##f) args; \
static some_func_##f my_func_##f = NULL;
同等のものを教えてください:
SOME_MACRO(void, myFunctionName, (int a));
ありがとう。
このマクロを考えると:
#define SOME_MACRO(ret, f, args) \
typedef ret (*some_func_##f) args; \
static some_func_##f my_func_##f = NULL;
同等のものを教えてください:
SOME_MACRO(void, myFunctionName, (int a));
ありがとう。
gccのフラグを使用して-E
、マクロがどのように展開されるかを確認できます。
typedef void (*some_func_myFunctionName) (int a); static some_func_myFunctionName my_func_myFunctionName = ((void *)0);;
static void (*my_func_myFunctionName) (int a) = NULL;
変数を、を取り、何も返さないmy_func_myFunctionName
関数への関数ポインタとして宣言します( )。変数をに初期化します。int
void
NULL
#define SOME_MACRO(ret, f, args) \
typedef ret (*some_func_##f) args; \
static some_func_##f my_func_##f = NULL;
SOME_MACRO(void、myFunctionName、(int a));
に翻訳されます
typedef void (*some_func_myFunctionName) (int a); //## concats myFunctionName to some_func_, ret becomes void
static some_func_myFunctionName my_func_myFunctionName = NULL;
##f concats myFunctionName to some_func_, ret becomes void args is (int a)