Archive 17/01/2023.

Call to `GetTypeInfoStatic` is ambiguous in class Texture3D

haolly

The macro URHO3D_OBJECT in class Texture3D complains Call to GetTypeInfoStatic is ambiguous when I open the project in Clion, but it compiles well on VS2017.

So I find the generated preprocessed file use the method described on SO here and replace the macro,

public:
		using ClassName = Texture3D;
		using BaseClassName = Texture;
		virtual Urho3D::StringHash GetType() const override { return GetTypeInfoStatic()->GetType(); }
		virtual const Urho3D::String& GetTypeName() const override { return GetTypeInfoStatic()->GetTypeName(); }
		virtual const Urho3D::TypeInfo* GetTypeInfo() const override { return GetTypeInfoStatic(); }
		static Urho3D::StringHash GetTypeStatic() { return GetTypeInfoStatic()->GetType(); }
		static const Urho3D::String& GetTypeNameStatic() { return GetTypeInfoStatic()->GetTypeName(); }
		static const Urho3D::TypeInfo* GetTypeInfoStatic()
		{
			static const Urho3D::TypeInfo typeInfoStatic("Texture3D",BaseClassName::GetTypeInfoStatic());
			return &typeInfoStatic;
		};

It turned out the code BaseClassName::GetTypeInfoStatic() cause this.

seems like Texture class does not define it’s owne GetTypeInfoStatic function, but inherit from Object/Resource/ResourceWithMetadata class, so it is ambigusou ??

It’s weird that VS does not report this issue
The same happens in class Texture2D

Eugene

Does it fix the problem if you add URHO3D_OBJECT to Texture?

haolly

URHO3D_OBJECT(Texture, ResourceWithMetadata);
yes, it does

haolly

May I ask one more question?

Does the line 416 use CreateTexture2D(&textureDesc, nullptr, (ID3D11Texture2D**)&object_); not CreateTexture2D(&textureDesc, nullptr, (ID3D11Texture2D**)&object_.ptr_); for a particular purpose ?
I see the latter was used in class Texture3D and TextureCube

Eugene

Non-functional typo, I think

haolly

Because object_ is an union, all share the same address memory :thinking: