dra*_*oot 3 c c++ c-preprocessor
#include指令中文件名的有效字符是什么?
在Linux下,例如,我可以使用几乎任何字符的情况除外/,并\0有一个有效的文件名,但我相信C预处理更加严格的有关文件的名字,我可以有。
在C ++中,源字符集在[lex.charset]中定义:
基本的源字符集由96个字符组成:空格字符,表示水平制表符,垂直制表符,换页符和换行符的控制字符,以及以下91个图形字符:14
abcdefghijklmnopqrstu vwxyz
ABCDEFGHIJKLMNOPQRSTU VWXYZ
0 1 2 3 4 5 6 7 8 9
_ {} []#()<>%:; 。?* +-/ ^&| 〜!=,\“'
并且#includes 的语法是源字符集中的任何东西,除了那些会干扰#include解析的字符:换行符和>/ dependent"([lex.header]):
Run Code Online (Sandbox Code Playgroud)header-name: < h-char-sequence > " q-char-sequence " h-char-sequence: h-char h-char-sequence h-char h-char: any member of the source character set except new-line and > q-char-sequence: q-char q-char-sequence q-char q-char: any member of the source character set except new-line and "
所以像这样的事情是完美†好的:
#include <hel& lo% world$@-".h>
#include ">.<>."
Run Code Online (Sandbox Code Playgroud)
†对于“完全”的某种定义...