参考博客:https://blog.csdn.net/cartzhang/article/details/72834164
在引擎中的定义:
// This pair of macros is used to help implement GENERATED_BODY() and GENERATED_USTRUCT_BODY() #define BODY_MACRO_COMBINE_INNER(A,B,C,D) A##B##C##D #define BODY_MACRO_COMBINE(A,B,C,D) BODY_MACRO_COMBINE_INNER(A,B,C,D) // Include a redundant semicolon at the end of the generated code block, so that intellisense parsers can start parsing // a new declaration if the line number/generated code is out of date. #define GENERATED_BODY_LEGACY(...) BODY_MACRO_COMBINE(CURRENT_FILE_ID,_,__LINE__,_GENERATED_BODY_LEGACY); #define GENERATED_BODY(...) BODY_MACRO_COMBINE(CURRENT_FILE_ID,_,__LINE__,_GENERATED_BODY); #define GENERATED_USTRUCT_BODY(...) GENERATED_BODY() #define GENERATED_UCLASS_BODY(...) GENERATED_BODY_LEGACY() #define GENERATED_UINTERFACE_BODY(...) GENERATED_BODY_LEGACY() #define GENERATED_IINTERFACE_BODY(...) GENERATED_BODY_LEGACY()
这边的逻辑顺序是:
GENERATED_BODY ————> BODY_MACRO_COMBINE ————> BODY_MACRO_COMBINE_INNER————>A##B##C##D
##在宏里的意思是合并两个string,
那么A##B##C##D 也就是CURRENT_FILE_ID_,__LINE__,_GENERATED_BODY
经过别人博客的提示,在generated.h最后一行有
#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID SVN_PROJECT_Source_FPSGame_Public_ShooterCharacter_h
其中 我猜CURRENT_FILE_ID 是原字符, SVN_PROJECT是项目目录名字, _Source_FPSGame_Public_ShooterCharacter_h是项目名字和class名字.