包含头文件时,路径是否区分大小写? [英] When including header files, is the path case sensitive?
问题描述
给定这个目录树:
src/MyLibrary/MyHeader.h
src/file.cpp
file.cpp:
#include "mylibrary/myheader.h"
...
编译 file.cpp 与 VS 一起工作,在 gcc 中失败.
Compiling file.cpp works with VS, fails in gcc.
- 标准怎么说?
- 如果路径区分大小写,为什么这样做是明智的?
- 最佳实践是什么,将所有文件/文件夹名称保持为小写,从而在包含时执行相同的操作?
谢谢.
推荐答案
区分大小写取决于操作系统.Windows 不区分大小写.Linux 是.
The case sensitivity depends on the Operating System. Windows is not case sensitive. Linux is.
实际上,正如 Martin York 的评论所观察到的那样,区分大小写取决于文件系统.默认情况下,Windows 使用不区分大小写的文件系统,而 Linux 使用区分大小写的文件系统.对于有兴趣了解哪些文件系统区分大小写哪些不区分大小写的人,维基百科上有一个完整的列表:文件名限制比较.
Actually, as observed by Martin York's comment, the case sensitivity depends on the file system. By default Windows uses a case insensitive file system, while Linux uses a case sensitive one. For whoever is interested to know which file systems are case sensitive and which aren't, there is a comprehensive list on Wikipedia: Comparison of file name limitations.
这篇关于包含头文件时,路径是否区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!