C ++为什么人们不使用大写字母来表示头文件? [英] C++ why people don't use uppercase in name of header files?

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

问题描述

我想知道为什么人们不用头文件的名字使用大写字母。我看到许多名称只有小写的头文件。但是我认为如果他们用大写字母写,比如说BaseClass.h,SubClass.h而不是baseballs.h,subclass.h,它会更容易阅读。这是为什么?
或者只是我看到的头文件只能以小写命名?

解决方案

那里区分大小写(* nix),并且有传统上不区分大小写的系统(Windows)。因此,如果你在* nix上开发并创建两个文件:baseclass.h和BaseClass.h - 你的代码将在* nix上编译得很好,但是当移动它到Windows,它甚至不会正确解包。另一方面,如果您在Windows上开发并且在编写'#includebaseclass.h'时拥有文件BaseClass.h,它将在不区分大小写的情况下进行编译Windows,但无法在* nix上编译。为避免这些麻烦,有一种不成文的(我认为)以小写字母使用所有文件名的惯例 - 至少它保证在任何地方以相同的方式工作。这种最不常见的方法,不会造成太多的不便。

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 "baseballs.h", "subclass.h". Why is that? Or it's just that the header files I've seen are named only in lowercase?

解决方案

There are systems out there which are case-sensitive (*nix), and there are systems which are traditionally case-insensitive (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.

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天全站免登陆