关于C/C ++中文件名下划线的任何规则? [英] Any rules about underscores in filenames in C/C++?

查看:204
本文介绍了关于C/C ++中文件名下划线的任何规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有在C/C ++的标识符中使用下划线的规则.在源代码文件名中有使用它们的规则吗?

I know that there are rules for using underscores in identifiers in C/C++. Are there any rules for using them in source code filenames?

例如,对于以下划线开头或结尾的文件名是否有任何限制?还是在下划线前加上下划线作为.c.h扩展名的最后一个字符?双下划线?

For instance, are there any restrictions against beginning or ending a filename with an underscore? Or having an underscore as the last character before the .c or .h extension? Double underscores?

如果有参考文献,将不胜感激.

References are appreciated, if there are any.

推荐答案

如果源文件受预处理器#include指令的约束,则C和C ++标准在文件名上指定了一组最低要求. C标准说:

If the source files are subject for preprocessor #include directives, then the C and C++ standards specify a minimum set of requirements on the filename. The C standard says:

6.10.2源文件包含

...

  1. 该实现应为由一个或多个非数字或数字(6.4.2.1)后跟一个句点(.)和单个非数字组成的序列提供唯一的映射.第一个字符不能是数字.该实现可能会忽略字母大小写的区别,并将映射限制为在句点之前的八个有效字符.

...,其中非数字包含字母A-Z,a-z 和下划线.

... where nondigit contains the letters A-Z, a-z and underscore.

在C ++标准的 16.2源文件包含中也可以找到完全相同的文本(段落编号除外).

The exact same text (except for the paragraph numbers) can also be found in the C++ standard, 16.2 Source file inclusion.

除此之外,有效文件名的传递取决于操作系统,文件系统,编译器,链接器和编译工具链的其他部分.

Beyond that, what passes for a valid filename depends on the operating system, file system, compiler, linker and other parts of the compilation tool chain.

这些天,我希望大多数现代系统都允许文件系统没有直接禁止的任何内容.

These days, I'd expect most modern systems to allow almost anything that isn't directly forbidden by the file system.

  • The final public draft of the C11 standard, n1570
  • The final public draft of the C++11 standard, n3337

这篇关于关于C/C ++中文件名下划线的任何规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆