更新时间:2023-11-17 19:27:16
结尾的 _ $ c $可以添加c>以避免与用户定义的标识符冲突。例如,您可能有一个名为
。因此,在 get.h
的头文件,并且同时可以想象有一个名为 GET_H get.h
中使用 GET_H
作为包含保护很容易导致问题。
The trailing _
might be added to avoid collision with user-defined identifiers. For example, you might have a header file named get.h
and at the same time you can conceivably have your own macro (or variable, or function) named GET_H
. So, using GET_H
for include guard in get.h
would easily lead to problems.
出于相同的目的,标准库头文件可能会使用前导 _
为其内部宏命名-避免名称与用户定义冲突身份标识。因此,语言规范明确禁止以 _
和大写字母开头的用户定义标识符。出于同样的原因,前导 _
不能用于包含防护的名称。
The standard library header files might use a leading _
to name its internal macros for the very same purpose - to avoid name collision with user-defined identifiers. For that reason, the language specification explicitly prohibits user-defined identifiers that begin with _
and a capital letter. And for the very same reason, the leading _
cannot be used in the names of include guards.
因此,Eclipse出于相同的目的决定使用跟踪 _
。它提供了合理的保护级别,以防止名称冲突,并且不违反语言规范的要求。
So, Eclipse decided to use a trailing _
for the very same purpose. It provides a reasonable level of protection from name collisions and does not violate the requirements of language specification.