Liste des Groupes | Revenir à cl c |
David Brown <david.brown@hesbynett.no> writes:I believe - but am not entirely sure - that the standard library headers are not allowed to include each other, precisely so that there will not be conflicts between user-defined identifiers and standard library identifiers from headers that you did not explicitly include.On 24/05/2024 21:29, Keith Thompson wrote:[...]Your header that defines your own "static_assert" macro might depend on"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.
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 andIndeed.
__STDC_VERSION__ for the keyword, etc.)
Perhaps it's not an issue for you, but it's a corner case to keep inIt is not an issue for me, no - but I agree that it can be an issue for some people, and I agree it is worth keeping in mind. I am not suggesting that defining your own static_assert macro is a good idea for general use - I was merely saying that /I/ had used it as a temporary measure before C11 (and C++11) became practical for the majority of work I did, and that it could have compatibility issues when moving to C23.
mind.
Les messages affichés proviennent d'usenet.