[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:48:13 UTC

--- Comment #4 from Dimitry Andric <dim@FreeBSD.org> ---
(In reply to Michał Górny from comment #3)
Well libc++'s <cstdio> simply includes <stdio.h>, so whatever applies to the
latter must also apply to the former, I think?

On e.g. macOS, stdio.h is simpler with respect to __stdoutp and friends:

#include <_stdio.h>

extern FILE *__stdinp;
extern FILE *__stdoutp;
extern FILE *__stderrp;

On Linux with glibc, there are no tricks with __, they just declare:

/* Standard streams.  */
extern FILE *stdin;             /* Standard input stream.  */
extern FILE *stdout;            /* Standard output stream.  */
extern FILE *stderr;            /* Standard error output stream.  */
/* C89/C99 say they're macros.  Make them happy.  */
#define stdin stdin
#define stdout stdout
#define stderr stderr

but there are various other defines that use _need_this and _need_that.

As far as I understand the modules system, this looks like one of the as-of-yet
unsolved problems in modules in general? I.e. should all system headers be
rewritten to "support" -fmodules? I don't think that is going to happen on many
operating systems..

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