c++ - 如何理解带参数的 `#define` ?

浏览:36日期:2023-03-17

问题描述

part1

VM_STRUCTS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, GENERATE_STATIC_VM_STRUCT_ENTRY, GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY, GENERATE_NONSTATIC_VM_STRUCT_ENTRY, GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY, GENERATE_C1_NONSTATIC_VM_STRUCT_ENTRY, GENERATE_C2_NONSTATIC_VM_STRUCT_ENTRY, GENERATE_C1_UNCHECKED_STATIC_VM_STRUCT_ENTRY, GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY)part2

//--------------------------------------------------------------------------------// VM_STRUCTS//// This list enumerates all of the fields the serviceability agent// needs to know about. Be sure to see also the type table below this one.// NOTE that there are platform-specific additions to this table in// vmStructs_<os>_<cpu>.hpp.#define VM_STRUCTS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c1_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field)

通常都是

#define type alias

可是这里我们看到是

#define type ___

我画下划线是表示nothing.

如果真的就这么“带人”替换掉,那部就是什么成了上面都没有吗,即便说你把参数都代入了,但是#define type ___是nothing啊。

这这么理解上面的语法呢?

源码来自jdk8.

问题解答

回答1:

帮你找到了完整源码了 http://hg.openjdk.java.net/jd...

从 50 行到 794 行,这些所有的代码都是一行。

后面并不是 nothing,而是后面有 700 多行代码。

相关文章: