问题描述
- 预编译连接符## 预处理指令
-
#include <stdio.h> #include<stdlib.h>
#define TR(m,n,p) m##n##p
int main ()
{
printf("%sn",TR("abc","xy","yz"));
return 0;
}
这段代码为什么编译不过?
解决方案
gcc?那好像要定义2个宏,可以看看这个解释http://www.cnblogs.com/wb-DarkHorse/p/3588787.html
解决方案二:
应该能编译过呀,你那边报的错误是什么?
解决方案三:
In function ‘main’:
define.c:7:19: error: pasting ""abc"" and ""xy"" does not give a valid preprocessing token
printf("%sn",TR("abc","xy","yz"));
^
define.c:3:20: note: in definition of macro ‘TR’
#define TR(m,n,o) m##n##o
^
define.c:7:25: error: pasting ""xy"" and ""yz"" does not give a valid preprocessing token
printf("%sn",TR("abc","xy","yz"));
^
define.c:3:23: note: in definition of macro ‘TR’
#define TR(m,n,o) m##n##o
时间: 2024-09-30 08:18:10