UTexture::UpdateResource() overwrote by winbase.h #define

I have a UTexture2D* variable called texture. UTexture2D has a function called UpdateResource(). WinBase.h has a macro called “UpdateResource” that calls “UpdateResourceW”. When I call “texture->UpdateResource();”, I get the error “class “UTexture2D” has no member “UpdateResourceW”” (despite not even including winbase.h). Going to the definition in VS takes me to that #define in WinBase.h. So that define in winbase is overwriting the function call, renaming it to UpdateResourceW somehow.

Do you actually get an error when you try to compile it or is it just intellisense being stupid?

It’s an actual error when I compile that makes the build fail, even when compiling from unreal engine.

fixed this by putting this at the top of the file where you are calling UpdateResource for the texture2d under the includes

#ifdef _WIN32
#undef UpdateResource
#endif

sorry for pinging the necro thread just hoping to help someone in the future from headaches

3 Likes

YOU SAVED MY LIFE

I think epic wants you to use this header instead.
include “Windows/WindowsHWrapper.h”

Using that there shouldn’t be any conflicts.