chrisaverage
chrisaverage

Reputation: 254

What is the proper way to configure GLM

Recently I enabled /W4 warnings (MSVC) to clean up a bit in my project and noticed that GLM uses non-standard compiler extension guarded by #define GLM_HAS_ANONYMOUS_UNION, that causes a very long warning spew.

There seems to be compiler feature detection mechanism, but I can't disable compiler extensions entirely because of Windows SDK dependencies and the /Za is discouraged as buggy anyway. So what is the proper way to disable that particular thing in GLM? I could slap an #undef everywhere i use GLM but is there a "proper" place to configure these things, like a separate config file or something? I'm upgrading GLM from time to time so I wouldn't want to modify that define in the GLM's code.

Upvotes: 2

Views: 756

Answers (1)

Richard
Richard

Reputation: 69

I ran into the same problem as you. GLM will try to use all capabilities of your compiler and if it detects VS it will use nonstandard extensions in order to do some fancy things.

If you want these non-standard things to go away (e.g. nameless unions/structs) you can switch GLM into standard mode by using

#define GLM_FORCE_CXX11 

just before you include any glm header.

I plugged this info from the manual at: http://glm.g-truc.net/0.9.7/glm-0.9.7.pdf

Alternatively you can look into disabling this very specific warning via pragma warning push

#pragma warning(push)
#pragma warning(disable:4201)   // suppress even more warnings about nameless structs
#include<glm/glm.hpp>
#pragma warning pop

more info at https://msdn.microsoft.com/en-us/library/aa273936(v=vs.60).aspx

Upvotes: 1

Related Questions