[Bug 264730] clang++ -fmodules fails when using stdout from cstdio: error: declaration of '__stdoutp' must be imported from module 'std.iosfwd' before it is required

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 18 Jun 2022 15:09:41 UTC

--- Comment #3 from Michał Górny <mgorny@gentoo.org> ---
Well, it wasn't my choice, really ;-).  Apparently use of gmodules was enabled
in LLDB's test suite on FreeBSD when the relevant tests were added — i.e. in
2016.  Unless I'm missing something, we've been doing some testing with them
since then.  I'm guessing there were some recent changes to clang or libc++
that made them more strict.

Ah, sorry, I don't think the 'wchar.h' part is actually the problem — I think
it just blames the wrong header.  The underlying problem is that the
stdout/stderr/stdin macros aren't visible from <cstdio>.

I know very little about modules myself but FWICS the purpose here is to avoid
relying on indirect includes.  I think textual header breaks that, i.e. the
following test program should fail:

#include <cstdio>

int main() {
  FILE *f;

With the original header variant, it fails as expected (just blames the wrong

$ clang++ -fmodules test.cxx 
test.cxx:4:3: error: missing '#include <wchar.h>'; 'FILE' must be declared
before it is used
  FILE *f;
/usr/include/wchar.h:109:24: note: declaration here is not visible
typedef struct __sFILE FILE;
1 error generated.

Changing `header` to `textual header` makes it build, so I think that goes
against the intent.  I suppose there must be a better way of solving
stdout/stderr/stdin problem.

You are receiving this mail because:
You are the assignee for the bug.