我有一个问题,好吧,似乎不应该发生。基类中的虚函数在“生成”文件中被覆盖,该文件创建头文件调用的宏。
覆盖的方法是virtual void GetLifetimeReplicatedProps( TArray< FLifetimeProperty > & OutLifetimeProps ) const OVERRIDE;
该语句位于生成文件(宏地狱,第二个代码块)中,该文件又插入到类定义的顶部,在常规标头(下面的第一个代码块)中。
直言不讳,这里是失败的代码:
类 .h 文件
UCLASS()
class AABaseInventoryItem : public AActor
{
GENERATED_UCLASS_BODY()
// Properties
UPROPERTY(Category = Item, BlueprintReadOnly, Replicated)
uint16 ItemIndex; // Unique item index
// Overrides
virtual void ReceiveActorBeginOverlap(AActor *OtherActor) OVERRIDE;
};
具有宏“GENERATED_UCLASS_BODY()”的 .h 文件
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
C++ class header boilerplate exported from UnrealHeaderTool.
This is automatically generated by the tools.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "ObjectBase.h"
#ifdef WTAGAME_ABaseInventoryItem_generated_h
#error "ABaseInventoryItem.generated.h already included, missing '#pragma once' in ABaseInventoryItem.h"
#endif
#define WTAGAME_ABaseInventoryItem_generated_h
#define AABaseInventoryItem_EVENTPARMS
#define AABaseInventoryItem_RPC_WRAPPERS
#define AABaseInventoryItem_CALLBACK_WRAPPERS
#define AABaseInventoryItem_INCLASS \
private: \
static void StaticRegisterNativesAABaseInventoryItem(); \
friend WTAGAME_API class UClass* Z_Construct_UClass_AABaseInventoryItem(); \
public: \
DECLARE_CLASS(AABaseInventoryItem, AActor, COMPILED_IN_FLAGS(0), 0, WTAGame, NO_API) \
/** Standard constructor, called after all reflected properties have been initialized */ NO_API AABaseInventoryItem(const class FPostConstructInitializeProperties& PCIP); \
DECLARE_SERIALIZER(AABaseInventoryItem) \
/** Indicates whether the class is compiled into the engine */ enum {IsIntrinsic=COMPILED_IN_INTRINSIC}; \
virtual void GetLifetimeReplicatedProps( TArray< FLifetimeProperty > & OutLifetimeProps ) const OVERRIDE;
#undef UCLASS_CURRENT_FILE_NAME
#define UCLASS_CURRENT_FILE_NAME AABaseInventoryItem
#undef UCLASS
#undef UINTERFACE
#define UCLASS(...) \
AABaseInventoryItem_EVENTPARMS
#undef GENERATED_UCLASS_BODY
#undef GENERATED_IINTERFACE_BODY
#define GENERATED_UCLASS_BODY() \
public: \
AABaseInventoryItem_RPC_WRAPPERS \
AABaseInventoryItem_CALLBACK_WRAPPERS \
AABaseInventoryItem_INCLASS \
public:
如果我将覆盖放在实际的头文件中,我会收到 C2535 编译器错误(成员函数已定义/声明)。然而,当我删除声明时,我得到一个未解决的外部符号错误(LNK2001),因为我已经在 CPP 文件中实现了它。所以,在我看来,MSVS 2013 没有正确读取生成的文件/宏,并抱怨?
无论如何,它正在破坏开发,因为我无法编译!任何帮助都是极好的。
谢谢,问候奥文德