gpt4 book ai didi

c++ - C 字符集 - 需要说明

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

我正在阅读 GCC C 预处理器 -> 标记化,其中提到

Preprocessing tokens fall into five broad classes:

  1. identifiers
  2. preprocessing numbers
  3. string literals
  4. punctuators
  5. other.

Any other single character is considered “other”. It is passed on to the preprocessor's output unmolested. The C compiler will almost certainly reject source code containing “other” tokens. In ASCII, the only other characters are ‘@’, ‘$’, ‘`’, and control characters other than NUL (all bits zero).

我也在浏览网页时遇到了“C 字符集”,其中他们提到“@”是字符之一。提到“@”作为“C 字符集”之一的文章是错误的吗?还是我的理解有误?

谢谢。

最佳答案

有一些编译器允许“额外”字符,例如@或$作为标识符的一部分。这不是标准的一部分,而是扩展。从内存中,它在 C++ 标准中以表示“编译器可能添加额外字符”的方式提及。

2.3 节:

The basic source character set consists of 96 characters: the space character, the control characters repre- senting horizontal tab, vertical tab, form feed, and new-line, plus the following 91 graphical characters:(14)

a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9
_ { } [ ] # ( ) < > % : ; . ? * + - / ^ & | ∼ ! = , \ " ’

(Note 14: The glyphs for the members of the basic source character set are intended to identify characters from the subset of ISO/IEC 10646 which corresponds to the ASCII character set. However, because the mapping from source file characters to the source character set (described in translation phase 1) is specified as implementation-defined, an implementation is required to document how the basic source characters are represented in source files.

关于c++ - C 字符集 - 需要说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17858122/

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