当不使用包含头文件后卫? [英] When not to use include guard in header file?
本文介绍了当不使用包含头文件后卫?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们都知道什么时候使用包括卫,但我们什么时候不是在我们的项目中使用它?
We all know when to use include guard, but when shall we not use it in our project?
最近,我看到了混合汇编(CUDA + GCC),一个头文件(CUDA文件)项目没有被特意留下包括后卫。我只是好奇吧。
Recently, I saw a project with mix compilation (CUDA + GCC), one header file (CUDA file) is deliberately left without include guard. I am just curious about it.
推荐答案
有2情景把我的头顶部:
There are 2 scenarios off the top of my head:
- 当你想打开/关闭调试能力(如何
ASSERT.H
作品) - X宏类型的功能,你必须包含文件执行2份的问题,诸如限定一个枚举然后定义字符串化名称的对应于该枚举的阵列
- when you want to turn on/off debugging capabilities (as how
assert.h
works) - for 'x-macro' type of functionality where you have the include file perform 2 parts of problem, such as defining an enum then defining an array of stringified names corresponding to the enums
这篇关于当不使用包含头文件后卫?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文