如何在连接期间扩展宏定义?

时间:2018-02-02 01:09:34

标签: c macros c-preprocessor

> cat | cpp -c
#define ORDER 3
#define APPEND_ORDER(name) name ## _ ## ORDER

void APPEND_ORDER(cg)(int arg)
{}
^D

我发现在参数替换期间,宏ORDER 正在展开。但这就是我想要的!

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"



void cg_ORDER(int arg)
{}

期望的输出:

void cg_3(int arg)
{}

0 个答案:

没有答案