UE5 Engine Code Complie Error ( PlaySound and PlaySoundW / GetObject() )

Hi!

UE5 Engnine Code Complie Error !!

enum class in file “AudioMixerQuantizedCommands.h” EQuartzCommandType::PlaySound return is enum name conflict Windows SDK PlaySoundW Define

and macro in file “JsonSerializerMaxros.h” #define Serializer.GetObject() Function name conflicts

This problem can be solved by renaming the enum or changing the function name of the macro, but I want to find another way.

I am a user using Photon Server.

If anyone knows how to solve this problem, please let me know, thanks.

2 Likes

The root problem is that the function “PlaySound()” is also a windows function, so there is a name collision if you or a third party lib is including Windows.h (or include a header file which includes windows.h somewhere in its dependency tree). It can be hard to find precisely which include files are including the windows.h file, but you need to find them all.

Once you have found the instances of “Windows.h”, you have to sandwich it like so:

#include "Windows/AllowWindowsPlatformTypes.h"

#include "Windows.h" //or whatever else

#include "Windows/HideWindowsPlatformTypes.h"

This is all you need. If you keep getting this error in spite of adding these include sandwiches, then you have multiple header files trying to include “Windows.h”! Gotta find them all and give them the same treatment.

This took me all day to figure out. I hope this helps someone else.