gpt4 book ai didi

c++ - 具有 n 个参数的宏

转载 作者:太空狗 更新时间:2023-10-29 21:08:59 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
C/C++: How to make a variadic macro (variable number of arguments)

只是想知道这是否完全可能。因此,我必须为每种情况使用许多不同的宏,而不是我当前如何处理具有多个参数的日志记录和消息,例如:

#define MSG(             msg                                    )
#define MSG1( fmt, arg1 )
#define MSG2( fmt, arg1, arg2 )
#define MSG3( fmt, arg1, arg2, arg3 )
#define MSG4( fmt, arg1, arg2, arg3, arg4 )
#define MSG5( fmt, arg1, arg2, arg3, arg4, arg5 )
#define MSG6( fmt, arg1, arg2, arg3, arg4, arg5, arg6)

有什么方法可以只定义一个可以接受任意数量参数的宏?

谢谢

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com