On Saturday 30 November 2024 00:53:08 Martin Storsjö wrote:
> On Wed, 27 Nov 2024, Pali Rohár wrote:
> 
> > C11 supports two-arg _Static_assert keyword
> > C++11 supports two-arg static_assert keyword
> > C++17 supports one-arg static_assert keyword
> > C23 supports one-arg static_assert keyword
> > 
> > So when possible expand _STATIC_ASSERT macro to the suitable C/C++ keyword.
> > ---
> > mingw-w64-headers/crt/crtdbg.h | 8 +++++++-
> > mingw-w64-headers/crt/malloc.h | 8 +++++++-
> > 2 files changed, 14 insertions(+), 2 deletions(-)
> 
> I believe this change is fine, but do we have any use of these anywhere? I
> guess that would only be if user code uses them somewhere - so it's not very
> obvious if this still works or not.

Yes, usage of those macros are for applications. VC++ header files also
contain this _STATIC_ASSERT macro and I saw it used in some applications.

This macro is useful when writing pre-C11/C++11 code. Or when writing
C11 code without C23 compiler support and want to write static assert
with automatic message (one arg variant) and do not want to invent
custom macro.

And I think it is better to use modern compiler keywords for static
asserts when they are available instead of old negative array size hack.

> (Feel free to push this, otherwise I can push it later.)
> 
> // Martin


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to