soloud icon indicating copy to clipboard operation
soloud copied to clipboard

#include <soloud.h> ostensily breaks STL with #define min()

Open Cons-Cat opened this issue 3 years ago • 2 comments

My team had a problem today. We #include <soloud.h>, which in turn includes <windows.h>. This causes std::min() to not compile elsewhere in the codebase, because windows.h defines a custom min() macro. This can be fixed by #define NOMINMAX right before the include of windows.h.

Currently we fix this by defining NOMINMAX before including soloud, but this was a source of much stress for us until we figured this out. I think it might be good for Soloud to make this define automatically on line 42 of soloud.h, right before including windows.h, to prevent this from being a problem in the first place. We tested that the define placed there does indeed fix the issue.

Cons-Cat avatar Sep 21 '21 23:09 Cons-Cat

IMHO windows.h should not be included by soloud.h. Just had a look at it and a forward declare of OutputDebugStringA() should be enough to replace the #include.

Green-Sky avatar Sep 22 '21 12:09 Green-Sky

Should, yes. I tried a few permutations with no success. As a workaround you can always define SOLOUD_NO_ASSERTS which also removes the include.

I do wonder, though, if printing to stderr leads somewhere sane in windows nowadays..

jarikomppa avatar Nov 15 '21 18:11 jarikomppa