C 包含路径 : Safe to use hyphen & underscore?

标签 c gcc include include-path

我意识到这可能是特定于操作系统的,但我正在尝试编写跨平台的 GCC 代码。所以想知道是否真的最好避免这些,或者如果我被迫选择,哪个是更安全的选择。

最佳答案

header 名称的语法是 (C11, 6.4.7 par. 1):

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
                       the new-line character and >
q-char-sequence:
       q-char
       q-char-sequence q-char
q-char:
          any member of the source character set except
                       the new-line character and "

-_ 都是基本源字符集的一部分(5.2.1 第 3 段)。但是该标准留下了很多与 #include 实现定义相关的内容。

在实践中,我没有发现使用它们有任何问题。我不知道有一个文件系统不允许或为它们分配特殊含义。 This Wikipedia article也没有列出一个。

关于C 包含路径 : Safe to use hyphen & underscore?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28497851/

相关文章:

c++ - 测量大型方形网格中的簇有哪些好的替代方法?

c - 如何在根级别在 C 中声明结构?

c - 我的程序在 gnu-gcc 上运行良好,但在 gnu gcc for avr 上运行不佳

c++ - 我无法使用 Code::Blocks 编译任何东西

c++ - 强制在 Mac 上对 C++ 代码使用前向声明(使用 Xcode)

c++ - 如何指定远程预处理器包含路径,如 192.0.2.17 ://usr/include

c - 我们如何删除未使用的 bss 符号?

c - 如何在 C 中动态分配内存和确定数组大小?

python-2.7 - 带有 "--enable-shared"标志的奇怪 Python 编译结果

html - 在 html 文件中包含 html 文件