Skip to content

gmacros.h: Use static_assert on MSVC if possible

Chun-wei Fan requested to merge msvc-static-assert into master

Hi,

This MR attempts to let Visual Studio builds use static_assert when it is possible, meaning that it is supported well when we are:

-Using C++ code on Visual Studio 2010 or later.

-Using plain-C code on Visual Studio 2013 or later.

Note that even if this is supported on Visual Studio 2010 and 2012 for plain-C code, the implementation of the static_assert macro does define some variables and carry out some things, which can break plain-C code builds on those compilers.

There is also a _STATIC_ASSERT macro that is available from crtdbg.h, but it seems that it produces a compiler error message that is not more intuitive than the current one that we already have, so I think we should not bother with that.

With blessings, thank you!

Merge request reports