为什么人们在C ++中的头文件名中不使用大写字母? [英] Why people don't use uppercase in the name of header files in C++?

查看:552
本文介绍了为什么人们在C ++中的头文件名中不使用大写字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么人们在头文件名中不使用大写字母.我看到许多头文件只用小写字母命名.但是我认为,如果他们使用大写字母(例如"BaseClass.h","SubClass.h")而不是"baseclass.h","subclass.h",则将它们更容易阅读.这是为什么? 还是仅仅是我看到的头文件只用小写字母命名?

I was wondering why people don't use uppercase in name of header files. I see many header files with name only in lowercase. But I thought it would be more easy to read if they write them with uppercase, say "BaseClass.h", "SubClass.h", instead of "baseclass.h", "subclass.h". Why is that? Or it's just that the header files I've seen are named only in lowercase?

推荐答案

有些系统区分大小写(* nix),而有些系统传统上不区分大小写(Windows).

There are systems out there which are case-sensitive (*nix), and there are systems which are traditionally case-insensitive (Windows).

因此,如果您在* nix上进行开发并创建两个文件:baseclass.h和BaseClass.h-您的代码将在* nix上正常编译,但是当将其移至Windows时,甚至无法正确解压缩该文件. .

As a result, if you develop on *nix and create two files: baseclass.h and BaseClass.h - your code will compile fine on *nix, but when moving it to Windows, it won't even unpack there properly.

另一方面,如果您在Windows上进行开发并且在编写"#include"baseclass.h"时具有文件BaseClass.h,则它将在不区分大小写的Windows上进行编译,但将无法在* nix上进行编译.

On the other hand, if you develop on Windows and have file BaseClass.h while writing '#include "baseclass.h"' - it will compile on case-insensitive Windows, but will fail to compile on *nix.

为避免这些麻烦,有一个不成文的(我认为)约定,即使用小写形式使用所有文件名-至少可以保证在所有地方都以相同的方式工作.一种最不常用的分母方法,不会给您带来太多不便.

To avoid these troubles, there is an unwritten (I think) convention of using all filenames in lowercase - at least it is guaranteed to work the same way everywhere. Kind of the least common denominator approach, which doesn't cause too much inconvenience.

这篇关于为什么人们在C ++中的头文件名中不使用大写字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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