[clang] [clang][docs] assert.h is not a good candidate for a textual header (PR #165057)
Ian Anderson via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 27 13:03:16 PDT 2025
ian-twilightcoder wrote:
> > As a textual header:
> > #define NDEBUG
> > #include <modular_header_that_has_an_assert.h>
>
> This isn't a problem with `<assert.h>`. If `<modular_header_that_has_an_assert.h>` intends to pick up the state of the `NDEBUG` macro from the translation unit that includes it, then it's not a modular header, and shouldn't be declared as one.
Sure, but if you can't include `<assert.h>` from a modular header, then that basically means `<assert.h>` can't itself be a modular header. `<modular_header_that_has_an_assert.h>` doesn't usually start its life as a modular header, it just has an inline function with an assert in it, and doesn't expect its behavior to change and start ignoring NDEBUG when it becomes a modular header. In a single module world, fine `<assert.h>` can function the same as textual, but when you add in a second world it starts behaving differently with and without modules.
https://github.com/llvm/llvm-project/pull/165057
More information about the cfe-commits
mailing list