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 :

https://stackoverflow.com/questions/13216423/error-pasting-and-red-does-not-give-a-valid-preprocessing-token

[To be continued]

macro expand error的更多相关文章

  1. 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 ...

  2. configure.ac:32: error: possibly undefined macro: AC_DEFINE

    在ubuntu 下编译snappy时,在检查依赖关系时,处理autoconf的包时,在相关依赖包都已经安装的情况下,报如下错误,死活不过. configure.ac:32: error: possib ...

  3. 解决error possibly undefined macro AC_MSG_ERROR

    问题 出现如下缺少宏的问题 error: possibly undefined macro: AC_MSG_ERROR error: possibly undefined macro: AC_SUBS ...

  4. 几个常用道的macro

    几个常用道的macro1.macro(1)#error msg 指令使編譯器停止執行並打印一條語句,(2)printf("%d,%s",_LINE_,_FILE_)打印當前行號和文 ...

  5. 从一个例子看现代C++的威力

    引子 最近准备重构一下我的kapok库,让meta函数可以返回元素为kv的tuple,例如: struct person { std::string name; int age; META(name, ...

  6. Linux基础 30分钟GDB调试快速突破

    引言 Linus心灵鸡汤 在*nix开发中有道卡叫gdb调试,不管你怎么搞. 它依然在那丝毫不会松动.今天致敬一个 活着的传奇 Linus Torvalds Unix 始于上个世纪60年代,在70年代 ...

  7. 《Debug Hacks》和调试技巧【转】

    转自:https://blog.csdn.net/sdulibh/article/details/46462529 Debug Hacks 作者为吉冈弘隆.大和一洋.大岩尚宏.安部东洋.吉田俊辅,有中 ...

  8. 优秀的gdb图形化前端调试器

    目前我自己最喜欢的还是 ddd . gdbgui 和 vim-vebugger插件或vimgdb插件 三种. You could try using Insight a graphical front ...

  9. Linux环境Nginx安装、调试以及PHP安装

    linux版本:64位CentOS 6.4 Nginx版本:nginx1.8.0 php版本:php5.5 1.编译安装Nginx 官网:http://wiki.nginx.org/Install 下 ...

随机推荐

  1. 正则表达式-基础知识Review

    正则表达式(Regular Expression)是计算机科学的一个概念. 正则表达式使用单个字符窜来描述.匹配一系列符合某个句法规则的字符窜. 在很多文本编辑器里, 正则表达式通常用来被检索替换哪些 ...

  2. 第二章JavaScript 函数和对象

    1 JavaScript 函数 1.1 声明函数的方式 function 关键字 匿名函数方式(表达式方式) Function 构造函数方式 1.2 参数问题 形参和实参数量问题 可选形参(参数默认值 ...

  3. 【PHP】PHP中的排序函数sort、asort、rsort、krsort、ksort区别分析

    php编程中有时候会需要用上排序,在这里简单地整理一下集中sort的区别,方便查询 sort() 函数用于对数组单元从低到高进行排序. rsort() 函数用于对数组单元从高到低进行排序. asort ...

  4. OpenFaceswap 入门教程(1):软件安装篇

    ---恢复内容开始--- 众多换脸软件中,DeepFaceLab其实是安装和使用最方便,更新最快的,但是由于其没有可是化界面,对于很新手来说,可能入门还是有点难度.那么今天就来介绍一款操作极其直观和简 ...

  5. Thinkphp 支付宝插件的引入 和调用

    本文版权归本宝宝所有 未得允许不得转载 下载地址传送门 https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.twLYka&am ...

  6. linux 服务器被植入ddgs、qW3xT.2挖矿病毒处理记录

    被入侵后的现象: 发现有qW3xT.2与ddgs两个异常进程,消耗了较高的cpu,kill掉后 过一会就会重新出现. kill 掉这两个异常进程后,过一段时间看到了如下进程: 首先在/etc/sysc ...

  7. Gender Equality in the Workplace【职场上的性别平等】

    Gender Equality in the Workplace A new batch of young women - members of the so-called Millennial ge ...

  8. Codeforces Round #461 (Div. 2) D. Robot Vacuum Cleaner

    D. Robot Vacuum Cleaner time limit per test 1 second memory limit per test 256 megabytes Problem Des ...

  9. 动态规划:HDU-2955-0-1背包问题:Robberies

    解题心得: 这题涉及概率问题,所以要运用概率的知识进行解答.题目要求不被抓到的概率,但是给出的是被抓到的概率,所要用1减去后得到答案.最好使用double类型,避免精度问题导致WA. 先算出可以抢劫的 ...

  10. poj1142 Smith Numbers

    Poj1142 Smith Numbers Smith Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13854 ...