Classes that inherit from the UE4 engine generate some macro code. The purpose of this macro code is to help generate constructors and associated member functions
UCLASS()
class SECTION1_API ASUsableActor : public AActor
{
GENERATED_BODY()
public:
};
UCLASS()
class SURVIVALGAME_API ASUsableActor : public AActor
{
GENERATED_UCLASS_BODY()
public:
};
F12 jumps to the declaration file for both macros
#define GENERATED_BODY() \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
ASUsableActor_RPC_WRAPPERS_NO_PURE_DECLS \
ASUsableActor_CALLBACK_WRAPPERS \
ASUsableActor_INCLASS_NO_PURE_DECLS \
ASUsableActor_ENHANCED_CONSTRUCTORS \
private: \
PRAGMA_POP
GENERATED_BODY() will be replaced by a series of macros that replace the bottommost member with private: that is, after GENERATED_BODY() without significantly changing the member’s access mode, it will be private
#define GENERATED_UCLASS_BODY() \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
ASUsableActor_RPC_WRAPPERS \
ASUsableActor_CALLBACK_WRAPPERS \
ASUsableActor_INCLASS \
ASUsableActor_STANDARD_CONSTRUCTORS \
public: \
PRAGMA_POP
and the member variable after GENERATED_UCLASS_BODY() is public.
#define ASUsableActor_RPC_WRAPPERS
#define ASUsableActor_CALLBACK_WRAPPERS
these two are empty macros, in C/C++ hollow macros will be replaced by Spaces mostly used to indicate comments
The two non-null macros in GENERATED_UCLASS_BODY() are declared as
#define ASUsableActor_INCLASS \
private: \
static void StaticRegisterNativesASUsableActor(); \
friend SECTION1_API class UClass* Z_Construct_UClass_ASUsableActor(); \
public: \
DECLARE_CLASS(ASUsableActor, AActor, COMPILED_IN_FLAGS(0), 0, Section1, NO_API) \
DECLARE_SERIALIZER(ASUsableActor) \
/** Indicates whether the class is compiled into the engine */ enum {IsIntrinsic=COMPILED_IN_INTRINSIC}; \
UObject* _getUObject() const { return const_cast<ASUsableActor*>(this); }
The main purpose of these lines is to declare some member methods for the class
#define ASUsableActor_STANDARD_CONSTRUCTORS \
/** Standard constructor, called after all reflected properties have been initialized */ \
NO_API ASUsableActor(const FObjectInitializer& ObjectInitializer); \
DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(ASUsableActor) \
private: \
/** Private copy-constructor, should never be used */ \
NO_API ASUsableActor(const ASUsableActor& InCopy); \
public:
Here you can see that a public constructor and a private copy constructor are declared, with the public constructor taking a reference constant for FObjectInitializer. The copy constructor is declared private, indicating that the copy constructor is not available
The following two are non-null macro declarations referenced in GENERATED_BODY()
#define ASUsableActor_RPC_WRAPPERS_NO_PURE_DECLS \
static inline void StaticChecks_Implementation_Validate() \
{ \
}
#define ASUsableActor_INCLASS_NO_PURE_DECLS \
private: \
static void StaticRegisterNativesASUsableActor(); \
friend SECTION1_API class UClass* Z_Construct_UClass_ASUsableActor(); \
public: \
DECLARE_CLASS(ASUsableActor, AActor, COMPILED_IN_FLAGS(0), 0, Section1, NO_API) \
DECLARE_SERIALIZER(ASUsableActor) \
/** Indicates whether the class is compiled into the engine */ enum {IsIntrinsic=COMPILED_IN_INTRINSIC}; \
UObject* _getUObject() const { return const_cast<ASUsableActor*>(this); }
#define ASUsableActor_ENHANCED_CONSTRUCTORS \
private: \
/** Private copy-constructor, should never be used */ \
NO_API ASUsableActor(const ASUsableActor& InCopy); \
public: \
DEFINE_DEFAULT_CONSTRUCTOR_CALL(ASUsableActor)
DEFINE_DEFAULT_CONSTRUCTOR_CALL didn’t track where and how to declare it in VS, so the literal definition is to define the default constructor, which is the basic constructor.
Also the copy constructor is not available
From the above analysis, you can think of GENERATED_BODY() as generating the default constructor for us, and GENERATED_UCLASS_BODY() as generating the constructor with the specified parameter type for us
Read More:
- XML tag has empty body less… (Ctrl+F1) Reports empty tag body. The validation works in XML / JSP
- Cannot find module ‘body-parser’
- Required request body is missing with ContentCachingRequestWrapper
- Example of public key signature and verification generated with fabric case
- curl: (23)failed writing body(0!=3810)
- curl.perform() pycurl.error: (23, ‘Failed writing body (0 != 59)’)
- TypeError: Failed to execute ‘fetch‘ on ‘Window‘: Request with GET/HEAD method cannot have body.
- Mybatis automatically generated SQL error
- Matlab: Three forms of random number generated (Rand, Randi and Randn)
- Error: required request body is missing, @ requestbody annotation usage
- T omcat:removeGeneratedFiles Failed to delete the generated java file solution
- The collapse pits of VTK projects that are not generated by cmake
- (Copy python package, the problem generated) pip Fatal error in launcher: Unable to create process using
- Error C1083 error msb3075 in UE4 generated by vs2019 debug editor
- The file is generated, but an error is still reported. Error: CreateProcess failed
- Vs generated an error: “error LNK 1168: unable to open xxxxxx.exe Write to
- Module in linux driver_ platform_ Learning driver macro
- Latex macro package and latex error: file ‘xxx. Sty’ not found
- Latex sets page margin, page size, page margin and geometry macro package
- OpenGL programming error analysis