macro expand error
cat test_macro.c
#define TEST_MACRO(b) chip->##b
int main(void)
{
TEST_MACRO(yyy)
return 0;
}
gcc -E test_macro.c
# 1 "test_macro.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "test_macro.c"
int main(void)
{
test_macro.c:1:29: error: pasting "->" and "yyy" does not give a valid preprocessing token
#define TEST_MACRO(b) chip->##b
^
test_macro.c:5:9: note: in expansion of macro ‘TEST_MACRO’
TEST_MACRO(yyy)
^
chip->yyy
return 0;
}
What's pasting in above block ?
It is often useful to merge two tokens into one while expanding macros. This is called token pasting or token concatenation.
Reference :
3.5 Concatenation in [The C Preprocessor] for GCC version 8.1.0]
Question :
What's valid preprocessing token ?
preprocessing-token:
- head-name
- identifer
- pp-number
- character-constant
- string-literal
- punctuator
- each non-white-space character that cannot be one of the above
Error message mean that "->" is not a valid preprocessing token ?
or
"->" is not a valid preprocessing token for operator "##" ?
Solve :
cat test_macro.c
#define TEST_MACRO(b) chip->b
int main(void)
{
TEST_MACRO(yyy)
return 0;
}
gcc -E test_macro.c
# 1 "test_macro.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "test_macro.c"
int main(void)
{
chip->yyy
return 0;
}
Reference :
[To be continued]
macro expand error的更多相关文章
- check source code after macro expand
Some time I'd like check source code after macro expand. We can use -E option to stop after the prep ...
- configure.ac:32: error: possibly undefined macro: AC_DEFINE
在ubuntu 下编译snappy时,在检查依赖关系时,处理autoconf的包时,在相关依赖包都已经安装的情况下,报如下错误,死活不过. configure.ac:32: error: possib ...
- 解决error possibly undefined macro AC_MSG_ERROR
问题 出现如下缺少宏的问题 error: possibly undefined macro: AC_MSG_ERROR error: possibly undefined macro: AC_SUBS ...
- 几个常用道的macro
几个常用道的macro1.macro(1)#error msg 指令使編譯器停止執行並打印一條語句,(2)printf("%d,%s",_LINE_,_FILE_)打印當前行號和文 ...
- 从一个例子看现代C++的威力
引子 最近准备重构一下我的kapok库,让meta函数可以返回元素为kv的tuple,例如: struct person { std::string name; int age; META(name, ...
- Linux基础 30分钟GDB调试快速突破
引言 Linus心灵鸡汤 在*nix开发中有道卡叫gdb调试,不管你怎么搞. 它依然在那丝毫不会松动.今天致敬一个 活着的传奇 Linus Torvalds Unix 始于上个世纪60年代,在70年代 ...
- 《Debug Hacks》和调试技巧【转】
转自:https://blog.csdn.net/sdulibh/article/details/46462529 Debug Hacks 作者为吉冈弘隆.大和一洋.大岩尚宏.安部东洋.吉田俊辅,有中 ...
- 优秀的gdb图形化前端调试器
目前我自己最喜欢的还是 ddd . gdbgui 和 vim-vebugger插件或vimgdb插件 三种. You could try using Insight a graphical front ...
- Linux环境Nginx安装、调试以及PHP安装
linux版本:64位CentOS 6.4 Nginx版本:nginx1.8.0 php版本:php5.5 1.编译安装Nginx 官网:http://wiki.nginx.org/Install 下 ...
随机推荐
- vue系列之vue cli 3引入ts
插件 Vue2.5+ Typescript 引入全面指南 vue-class-component强化 Vue 组件,使用 TypeScript/装饰器 增强 Vue 组件 vue-property-d ...
- php中关于empty()函数是否为真的判断
<?php// $a = 0; ==> 符合empty,empty($a)为true// $a = '0'; ==> 符合empty,empty($a)为true// $a = ...
- Python 文件操作Error: binary mode doesn't take an encoding argument
Python 报错:ValueError: binary mode doesn't take an encoding argument 在运行文件操作相关功能时报错:ValueError: binar ...
- OAuth2.0 social_django微博第三方登录
python网站第三方登录,social-auth-app-django模块, social-auth-app-django模块是专门用于Django的第三方登录OAuth2协议模块 目前流行的第三方 ...
- 662. Maximum Width of Binary Tree
https://leetcode.com/problems/maximum-width-of-binary-tree/description/ /** * Definition for a binar ...
- [BSOJ2684]锯木厂选址(斜率优化)
Description 从山顶上到山底下沿着一条直线种植了n棵老树.当地的政府决定把他们砍下来.为了不浪费任何一棵木材,树被砍倒后要运送到锯木厂.木材只能按照一个方向运输:朝山下运.山脚下有一个锯木厂 ...
- 牛客第四次多校Maximum Mode
链接:https://www.nowcoder.com/acm/contest/142/G来源:牛客网 题目描述 The mode of an integer sequence is the valu ...
- 笔记-python-build-in-types
笔记-python-build-in-types 注:文档内容来源为Python 3.6.5 documentation 1. built-in types 1.1. 真值测试 所有对 ...
- centos6.4编译hadoop2.4源码
4.1.环境: 1)Linux 64 位操作系统,CentOS 6.4 版本,VMWare 搭建的虚拟机 2)虚拟机可以联网 4.2.官方编译说明: 解压命令:tar -zxvf hadoop-2.4 ...
- JAVA后端常用框架SSM,redis,dubbo等
JAVA后端常用框架SSM,redis,dubbo等 一.SpringMVC http://blog.csdn.net/evankaka/article/details/45501811 spri ...