sinbad / SPUD

Steve's Persistent Unreal Data library
MIT License
308 stars 45 forks source link

Declaration Shadows a Field of USpudStateCustomData #17

Closed renardmf closed 2 years ago

renardmf commented 2 years ago

Hello,

I was having issues compiling under clang for PS5 receiving these errors:

...\Plugins\SPUD\Source\SPUD\Public/SpudState.h(371,2): error : declaration shadows a field of 'USpudStateCustomData' [-Werror,-Wshadow]

On line 371 of SpudState.h:

UCLASS() class SPUD_API USpudStateCustomData : public UObject { ---> GENERATED_BODY()

Any help with this issue would be much appreciated.

Thanks! Andrew

sinbad commented 2 years ago

Sorry I don't have this environment to test in. Is there anything else in the output, it seems like it's missing the part where it tells you which variable is doing the shadowing.

Aj-Jones commented 2 years ago

Looking into this, it looks like the FArchive* Ar delcared on 373 could be to blame. The UObject source uses FArchive Ar as an argument in a couple of functions, which could lead to this issue.

sinbad commented 2 years ago

@Aj-Jones thanks for the suggestion, @renardmf could you try changing the name to see if that helps in your env?

Aj-Jones commented 2 years ago

Took a look at this today(I'm working with @renardmf ), although changing the name does fix that issue, the compiler then has an issue with the SpudTypeInfo<> 's declared in SpudProprertyUtil.h. Each of the various EnumTypes is shown as a duplicate symbol, and thus throws an error.

sinbad commented 2 years ago

Having not really had to deal with it since Ogre 10+ years ago, I'd forgotten how much of a pain C++ compiler inconsistencies can be 😑 I assume this is some nuance of template specialisation syntax between MSVC and Clang.

I've been told the best way to test Clang without a console devkit is to use the Linux cross-compilation path so I'm going to try to get that set up, although I might not get to it for a week or two.

Aj-Jones commented 2 years ago

I believe I was actually able to fix this error. By placing the templates that exist in SpudPropertyUtil.h into an un-named namespace, it prevents it from violating ODR. https://stackoverflow.com/questions/64610024/duplicate-symbols-with-global-template-variable-using-clang

I opened PR #18 with the fixes in place. Thanks a bunch for the plugin!

sinbad commented 2 years ago

Awesome, thanks!