Skip to content

Commit 19bee65

Browse files
committed
mcpp module: report() writes through printf, so no FILE reaches the interface (#734 E11)
GCC rejected a build program that includes <cstdio> after 'import mcpp;' once an inline function of the interface named stdout and fputc: the BMI then carried struct _IO_FILE, and the textual include conflicted with it. e2e 651 read the defect on the GCC row.
1 parent 0de80d7 commit 19bee65

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

‎src/build/hostprogram.cppm‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,20 @@ struct diagnostic {
114114
const char* impact = "";
115115
const char* hint = "";
116116
};
117-
inline void diagnostic_field_(const char* s) {
117+
// Output goes through printf only: an inline function of this interface that
118+
// names `stdout` or `fputc` carries `FILE` into the module, and GCC then
119+
// rejects a build program that includes <cstdio> after `import mcpp;`.
120+
inline void diagnostic_field_(const char* s, char end) {
118121
for (const char* p = s ? s : ""; *p; ++p)
119-
std::fputc((*p == '\t' || *p == '\n' || *p == '\r') ? ' ' : *p, stdout);
122+
std::printf("%c", (*p == '\t' || *p == '\n' || *p == '\r') ? ' ' : *p);
123+
std::printf("%c", end);
120124
}
121125
inline void report(const diagnostic& d) {
122-
std::fputs("mcpp:diagnostic=", stdout);
123-
diagnostic_field_(d.severity); std::fputc('\t', stdout);
124-
diagnostic_field_(d.message); std::fputc('\t', stdout);
125-
diagnostic_field_(d.impact); std::fputc('\t', stdout);
126-
diagnostic_field_(d.hint); std::fputc('\n', stdout);
126+
std::printf("mcpp:diagnostic=");
127+
diagnostic_field_(d.severity, '\t');
128+
diagnostic_field_(d.message, '\t');
129+
diagnostic_field_(d.impact, '\t');
130+
diagnostic_field_(d.hint, '\n');
127131
}
128132
129133
// ── The probe channel (mcpp 2026.9.5.2+) ────────────────────────────────────

0 commit comments

Comments
 (0)