Variadic Macros

WPS Office JS宏实现文件和数据的上传及下载 WPS Office JS宏下载、上传文件;通过加载项实现数据的获取和上传。 阅读详情

Variadic Macros

A macro can be declared to accept a variable number of arguments much asa function can. The syntax for defining the macro is similar to that ofa function. Here is an example:

     #define eprintf(...) fprintf (stderr, __VA_ARGS__)

This kind of macro is called variadic. When the macro is invoked,all the tokens in its argument list after the last named argument (thismacro has none), including any commas, become the variableargument. This sequence of tokens replaces the identifier__VA_ARGS__ in the macro body wherever it appears. Thus, wehave this expansion:

     eprintf ("%s:%d: ", input_file, lineno)
          ==>  fprintf (stderr, "%s:%d: ", input_file, lineno)

The variable argument is completely macro-expanded before it is insertedinto the macro expansion, just like an ordinary argument. You may usethe ‘#’ and ‘##’ operators to stringify the variable argumentor to paste its leading or trailing token with another token. (But seebelow for an important special case for ‘##’.)

If your macro is complicated, you may want a more descriptive name forthe variable argument than __VA_ARGS__. CPP permitsthis, as an extension. You may write an argument name immediatelybefore the ‘...’; that name is used for the variable argument. The eprintf macro above could be written

     #define eprintf(args...) fprintf (stderr, args)

using this extension. You cannot use __VA_ARGS__ and thisextension in the same macro.

You can have named arguments as well as variable arguments in a variadicmacro. We could define eprintf like this, instead:

     #define eprintf(format, ...) fprintf (stderr, format, __VA_ARGS__)

This formulation looks more descriptive, but unfortunately it is lessflexible: you must now supply at least one argument after the formatstring. In standard C, you cannot omit the comma separating the namedargument from the variable arguments. Furthermore, if you leave thevariable argument empty, you will get a syntax error, becausethere will be an extra comma after the format string.

     eprintf("success!\n", );
          ==> fprintf(stderr, "success!\n", );

GNU CPP has a pair of extensions which deal with this problem. First,you are allowed to leave the variable argument out entirely:

     eprintf ("success!\n")
          ==> fprintf(stderr, "success!\n", );

Second, the ‘##’ token paste operator has a special meaning whenplaced between a comma and a variable argument. If you write

     #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__)

and the variable argument is left out when the eprintf macro isused, then the comma before the ‘##’ will be deleted. This doesnot happen if you pass an empty argument, nor does it happen ifthe token preceding ‘##’ is anything other than a comma.

     eprintf ("success!\n")
          ==> fprintf(stderr, "success!\n");

The above explanation is ambiguous about the case where the only macroparameter is a variable arguments parameter, as it is meaningless totry to distinguish whether no argument at all is an empty argument ora missing argument. In this case the C99 standard is clear that thecomma must remain, however the existing GCC extension used to swallowthe comma. So CPP retains the comma when conforming to a specific Cstandard, and drops it otherwise.

C99 mandates that the only place the identifier __VA_ARGS__can appear is in the replacement list of a variadic macro. It may notbe used as a macro name, macro argument name, or within a different typeof macro. It may also be forbidden in open text; the standard isambiguous. We recommend you avoid using it except for its definedpurpose.

Variadic macros are a new feature in C99. GNU CPP has supported themfor a long time, but only with a named variable argument(‘args...’, not ‘...’ and __VA_ARGS__). If you areconcerned with portability to previous versions of GCC, you should useonly named variable arguments. On the other hand, if you are concernedwith portability to other conforming implementations of C99, you shoulduse only __VA_ARGS__.

Previous versions of CPP implemented the comma-deletion extensionmuch more generally. We have restricted it in this release to minimizethe differences from C99. To get the same effect with both this andprevious versions of GCC, the token preceding the special ‘##’ mustbe a comma, and there must be white space between that comma andwhatever comes immediately before it:

     #define eprintf(format, args...) fprintf (stderr, format , ##args)

See Differences from previous versions, for the gory details.


2026最新openclaw(clawbot/moltbot)真正在自己个人电脑上搭建部署,配置飞书远程远程让AI助理操控电脑完成任务,以及结合ollama无限token实现7*24小时工作(附配置) 2026最新openclaw(clawbot/moltbot)真正在自己个人电脑上搭建部署,配置飞书远程远程让AI助理操控电脑完成任务,以及结合 ollama 无限token实现7*24小时工作,以及部署安装需要的 skills 完成复杂的工作任务(附完整可以运行的配置文件)。 很多人已经会配置安装 openclaw 了 ,但是 安装完成之后真正让电脑自动运行起来的很好,完成出色工作的更少,最常见的就是聊聊天,或者执行一些简单的命令,理解要让电脑自动化工作,openclaw、skills、大模型这三样。 阅读详情

相关推荐

工创赛智能搬运小车实战:视觉定位、底盘控制与RTOS调度

智能搬运系统是嵌入式控制与机器视觉融合的典型工程实践,其核心在于视觉定位精度、运动控制稳定性与实时任务调度能力。在有限算力(如STM32H7)、低功耗约束和结构化场景下,传统CV方法(如FAST+RANSAC)比轻量级深度学习更具鲁棒性与实时性;而底盘控制需穿透PID表层,直击死区补偿、编码器硬件滤波与负载自适应等物理层细节;RTOS则不是炫技工具,而是保障多模块时序确定性的刚需——尤其在视觉-控制-执行强耦合链路中,任务优先级、事件组通信与栈安全直接影响系统存活。本文聚焦全国大学生工程训练竞赛(工创赛)真

weixin_29194693的博客 267

【转】gcc编译错误表

conversion from %s to %s not supported by iconv” iconv 不支持从 %s 到 %s 的转换” iconv_open” iconv_open” no iconv implementation, cannot convert from %s to %s” 没有 iconv 的实现,无法从 %s 转换到 %s” character 0x%l

wdt3385的专栏 5279

基于YOLOv8和PaddlepaddleOCR的微信截图聊天记录提取

本文提出了一种基于YOLOv8和PaddleOCR的微信聊天记录提取方法。首先使用YOLOv8n模型分割出聊天气泡(针对深浅色模式分别训练),通过合成数据集增强模型鲁棒性,召回率达0.995。随后采用PP-OCRv5进行文本识别,利用坐标匹配将气泡内文本送入识别队列,短长文本平均置信度分别>0.98和>0.95。文中特别强调了PaddleOCR不同版本的输出格式差异及适配方案,建议使用3.0+版本。该方法有效解决了直接OCR识别易受干扰的问题,通过气泡分割+文本定位的两阶段策略显著提升了识别准确

2401_87383958的博客 2354

基于C99标准的C语言coding技巧

使用C语言的一些小技巧

weixin_42993602的博客 847

基于STM32的超声波流量计设计

本项目基于STM32微控制器设计了一种超声波流量计,采用时间差法测量液体或气体的流速,计算流量并通过显示屏实时显示,同时支持远程数据传输。本设计通过STM32微控制器实现了基于时间差法的超声波流量计,集成了超声波信号采集、流量计算、状态显示和远程通信功能。本系统需要实现超声波信号的实时采集与处理,计算流速和流量,并将数据通过OLED显示和无线模块上传。系统需具备高精度的时间测量能力和良好的抗干扰能力。通过计算超声波在顺流和逆流方向上的传播时间差,结合管道直径与流体特性,计算流速并进一步计算流量。

stm32d1219的博客 2348

使用TMS320F28335控制四位共阳数码管

简要阐述利用F28335控制四位共阳数码管的整个过程,包括原理、思路、部分代码以及调试过程。

liujunhaozuishuai的博客 2659

C/C++变长参数宏(Variadic Macros)

A macro can be declared to accept a variable number of arguments much as a function can. The syntax for defining the macro is similar to that of a function. Here is an example: #define eprintf(.

origin_lee的专栏 3126

【免费】最新区块链钱包和私钥的助记词碰撞器,使用python开发

最新钱包私钥助记词碰撞器,搏一搏单车变摩托!

weixin_48529185的博客 1万+

c++11 : Variadic Macros(变长参宏)

Variadic macros are function-like macros that contain a variable number of arguments. Remarks To use variadic macros, the ellipsis may be specified as the final formal argument in a macro...

weixin_30482383的博客 507

(三)UPF之Domain Coverage Relationship(Cover、Equivalent、Independent)

整个Soc架构中一般会存在多个Power Domain,不同的Power Domain之间也存在着一定的Coverage关系。在Cadence工具中,这种。不同的Domain Coverage关系中,各个Domain存在着一定的关联()。

Mr.翟的博客 1424

SpringBoot一次请求中缓存数据,请求结束就清除的4种方法,你会几种?

通过以上四种方法,你可以在 SpringBoot 的一次请求中缓存数据,并在请求结束后自动清除这些缓存数据。使用 ThreadLocal:适用于需要跨多个方法调用的缓存数据,灵活性高,但需要注意内存泄漏问题。使用 AOP:适用于全局性的缓存管理,代码更加优雅,但需要对 AOP 有一定的了解。使用 ServletRequestListener:适用于简单的请求生命周期管理,配置简单,但功能相对有限。使用 HttpServletRequest 的 setAttribute 和 getAttribute。

java专栏 1295

C语言预处理

By francis_hao May 27,2017 预处理器执行宏替换、条件编译以及包含指定的文件。以#开头的命令行(#前可以有空格)就是预处理的对象,这些命令行的语法独立于语言的其他部分,它们可以出现在任何地方,作用范围是从出现的位置到文件末尾,除非使用显式的取消操作的预处理(undef)。这是一个独立的过程,与之后的编译,汇编和链接相当。 宏定义和扩展 宏定义有两种形式,"...

weixin_30268071的博客 304

【人工智能】拒绝焦虑,理性突围:AI 时代 Java 工程师的职业重构与进化指南

摘要:在AI技术快速发展的背景下,Java工程师面临职业转型挑战。本文通过MECE原则解构工作内容,划分高替代风险区(如CRUD开发)、高增效潜能区(如逻辑优化)和高核心壁垒区(如架构设计),指出AI对不同任务的影响程度。从劳动经济学视角分析行业将呈现K型分化,初级执行者被替代,而精通AI协作的全栈工程师需求增长。文章强调警惕过度依赖AI导致认知能力退化,并提出转型路径:掌握AI驱动开发(AIDD)、深耕领域驱动设计(DDD)、拓展全流程能力及AI原生应用开发。最终结论指出,未来的核心竞争力在于结合AI工具

奶爸的编程之路,也就一周冷个三天 135

可变参数宏(variadic macros)

C99标准支持可变参数宏(variadic macros), 定义一个自己的LOG打印宏: #define MY_LOG(fmt, ...) do{ \     printf("[%s:%d][%s] " fmt "\n", \     __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); \     } while (0) void test(...

mu_xixi的博客 640

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

GCC Variadic Macros

http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

voice_shen的专栏 882

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

GNU C和C99标准中的可变参数宏(variadic macros)

用可变参数宏(variadic macros)传递可变参数表 你可能很熟悉在函数中使用可变参数表,如: void printf(const char* format, …); 直到最近,可变参数表还是只能应用在真正的函数中,不能使用在宏中。 C99编译器标准终于改变了这种局面,它允许你可以定义可变参数宏(variadic macros),这样你就可以使用拥有可以变化的参数表的宏。可变参数宏

不是码农 2808

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

介绍GNU C和C99标准中的可变参数宏(variadic macros)

转载自:http://www.upsdn.net/html/2006-08/692.html   在 GNU C 中,宏可以接受可变数目的参数,就象函数一样,例如: #define pr_debug(fmt,arg...) / printk(KERN_DEBUG fmt,

w_ww_w的专栏 1374

用可变参数宏(variadic macros)传递可变参数表

你可能很熟悉在函数中使用可变参数表,如:  void printf(const char* format, …);直到最近,可变参数表还是只能应用在真正的函数中,不能使用在宏中。C99编译器标准终于改变了这种局面,它允许你可以定义可变参数宏(variadic macros),这样你就可以使用拥有可以变化的参数表的宏。可变参数宏就像下面这个样子:#define debug(…) prin

!VChen的专栏 596

gnu c语言可变参数,GNU C和C99标准中的可变参数宏(variadic macros)

用可变参数宏(variadic macros)传递可变参数表你可能很熟悉在函数中使用可变参数表,如:void printf(const char* format, …);直到最近,可变参数表还是只能应用在真正的函数中,不能使用在宏中。C99编译器标准终于改变了这种局面,它允许你可以定义可变参数宏(variadic macros),这样你就可以使用拥有可以变化的参数表的宏。可变参数宏就像下面这个样子...

weixin_39569753的博客 385

[转载]用可变参数宏(variadic macros)传递可变参数表

注意:_VA_ARGS__ 从VS2005才开始支持 在 GNU C 中,宏可以接受可变数目的参数,就象函数一样,例如: #define pr_debug(fmt,arg...) printk(KERN_DEBUG fmt,##arg) 用可变参数宏(variadic macros)传递可变参数表 你可能很熟悉在函数中使用可变参数表,如: void printf(const char* forma...

weixin_33943347的博客 93

[转]可变参数宏 , Variadic Macros

说起可变参数,立即想到的就是printf(),scanf()了。可变参数就是有一个固定的格式控制参数,后面再根据格式控制参数接若干参数。 这里先讨论可变参数宏。 我们一般在Debug需要打印调试信息的时候,需要可变参数的宏。 一, vc(C99)的复杂宏。 参考msdn(http://msdn2.microsoft.com/en-us/library/ms177415.aspx )。使用这种复杂宏时,省略号是格式控制参数,而标识符__VA_AR

CK_LK的专栏 624

用可变参数宏(variadic macros)传递可变参数表void printf(const char* format, …);

在 GNU C 中,宏可以接受可变数目的参数,就象函数一样,例如: #define pr_debug(fmt,arg...) \ printk(KERN_DEBUG fmt,##arg) 用可变参数宏(variadic macros)传递可变参数表 你可能很熟

佛系程序员 1019

【转】C/C++变长参数宏(Variadic Macros)

宏也可以有省略号(...)!

qaqwqaqwq的博客 762

可变参数宏 , Variadic Macros

说起可变参数,立即想到的就是printf(),scanf()了。可变参数就是有一个固定的格式控制参数,后面再根据格式控制参数接若干参数。          这里先讨论可变参数宏。         我们一般在Debug需要打印调试信息的时候,需要可变参数的宏。         一, vc(C99)的复杂宏。        参考msdn(http://msdn2.microso

1091
上一篇: Stringification in C
下一篇: No Memory Alignment with GCC
michaelrun
博客等级 码龄19年 93粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值