Source line length limit

*爱你&永不变心* 提交于 2019-12-01 02:10:55

C++2003, Annex B, (informative) Implementation quantities (sorry, don't have C++2011 handy)

2) The limits may constrain quantities that include those described below or others. The bracketed number following each quantity is recommended as the minimum for that quantity. However, these quantities are only guidelines and do not determine compliance.

  • Characters in one logical source line [65 536].

You didn't ask about these, but they might be useful, also:

  • Nesting levels of parenthesized expressions within a full expression [256].
  • Macro identifiers simultaneously defined in one translation unit [65 536].
  • Arguments in one macro invocation [256].
  • Number of characters in an internal identifier or macro name [1 024].
  • Macro identifiers simultaneously defined in one translation unit [65 536].
  • Parameters in one macro definition [256].


Postscript: It is worth noting what "one logical source line" is. A logical source line is what you have after:
  • Physical source file characters are mapped to the basic source character set
  • Trigraph sequences (2.3) are replaced by corresponding single-character internal representations
  • Each instance of a new-line character and an immediately preceding backslash character is deleted

The logical source line is what you have before:

  • The source file is decomposed into preprocessing tokens
  • Preprocessing directives are executed and macro invocations are expanded.

[quotes from C++ 2003, 2.1 Phases of Translation]

So, if the OP's concern is that the macros expand to beyond a reasonable line length, my answer is irrelevant. If the OP's concern is that his source code (after dealing with \, \n) might be too long, my answer stands.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!