gpt4 book ai didi

c - 预处理器 __VA_ARGS__ 长度的限制?

转载 作者:太空宇宙 更新时间:2023-11-04 02:28:33 24 4
gpt4 key购买 nike

我正在为 SQL 代码使用预处理器宏 va_args hack,以允许直接粘贴到 sqlite3.exe 中以进行快速的非构建调试:

#define QUOTE(...) #__VA_ARGS__
char const example[] = QUOTE(
INSERT INTO Some_Table(p, q) VALUES(?, ?);
);

https://stackoverflow.com/a/17996915/1848654

然而,这并不是 __VA_ARGS__ 应该使用的方式。特别是我的 SQL 代码包含数百个标记。

__VA_ARGS__ 长度的限制是多少(如果有)?

最佳答案

我唯一能找到的是 C99 中的这一点(C11 仍然包含相同的文本):

5.2.4.1 Translation limits

  1. The implementation shall be able to translate and execute at least one program that contains at least one instance of every one of the following limits:13)

    • [...]
    • 127 arguments in one macro invocation
    • [...]
    • 4095 characters in a character string literal or wide string literal (after concatenation)
    • [...]

[...]

13) Implementations should avoid imposing fixed translation limits whenever possible.

所以根据标准没有固定的限制。您将必须检查您的编译器是否记录了任何限制,或者只是尝试支持您抛给它的任何东西(直到它用完 RAM 或其他东西)。

关于c - 预处理器 __VA_ARGS__ 长度的限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47250287/

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