c - 为什么这段代码会出错?

标签 c macros output

<分区>

#define cat(x,y) x##y
main()
{
    printf("%d",cat(cat(cat(3,3),cat(3,4)),5));
}

为什么会报错? 据我所知O/P应该是

    cat(cat(3,3),cat(3,4)),5

因为连接内部宏没有扩展。为什么这没有发生?

最佳答案

间接调用。

#define cat_(x,y) x##y
#define cat(x,y) cat_(x,y)

关于c - 为什么这段代码会出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30916004/

相关文章:

c - 如何在 ubuntu 上编译内核 3.14(从 kernel.org 下载)

c - Pthread_join() 卡在线程数组上

visual-studio - 为 Visual Studio 2010 自定义宏分配键盘快捷键

c++ - C++ 能否定义宏将浮点文字重写为 double 文字或至少删除 f 后缀?

我可以用 Perl 获取 sizeof (C 中的字节长度)吗?

c - 排序算法的错误行为

c - 冗余的 if-else 如何帮助优化?

php - 实时处理大量查询和输出

python - 括号和单引号中的 Argparse 文件输出

php - ORDER BY 子句在输出中显示数字