C ++ #ifndef用于包含文件,为什么所有大写字母都用于头文件? [英] C++ #ifndef for include files, why is all caps used for the header file?

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

问题描述

我想知道为什么 #ifndef 指令后的名称总是大写,而且似乎与实际头文件的名称不匹配?有关这方面的规则是什么?我一直在网上浏览,但是没有找到任何解释。如果我的头文件名为myheader.h,那么可以使用:

I wonder why the name after the #ifndef directive is always all caps and don't seem to match the name of the actual header file? What are the rules surrounding this? I've been looking around the webs but, I haven't found any explanation for this. If my header file is called myheader.h would it then be ok to use:

#ifndef MYHEADER

如果是,为什么?规则是什么?

If so, why? What are the rules?

推荐答案

这些是预处理器符号,没有此类规则。 (只要它们与标题中的 #defines 匹配)

These are preprocessor symbols and have no such rules. (as long as they match the #defines in the headers)

但是,习惯上使用全大写用于预处理器符号。

However, convention is to use all-caps for preprocessor symbols.

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

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