Sujet : Re: C23 thoughts and opinions
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 26. May 2024, 00:21:05
Autres entêtes
Organisation : None to speak of
Message-ID : <87ed9p1nry.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
David Brown <
david.brown@hesbynett.no> writes:
On 24/05/2024 21:29, Keith Thompson wrote:
[...]
"static_assert" is already a macro defined in <assert.h> starting in
C11. The above code is valid in pre-C23, but will break in C11 and C17
if it includes <assert.h> directly or indirectly.
>
Yes. But including <assert.h> is optional.
Your header that defines your own "static_assert" macro might depend on
some other header outside your control. A future version of that other
header might add a "#include <assert.h>", breaking your code.
There are solutions (check "#ifdef static_assert" for the macro and
__STDC_VERSION__ for the keyword, etc.)
Perhaps it's not an issue for you, but it's a corner case to keep in
mind.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */