You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C/C++: a documentation or comment line ending in \ splices the next line of code into the comment, so the output fails to compile #148
LanguageGeneratorBase.WriteComment (Coder/Languages/LanguageGeneratorBase.cs:234-245) writes each comment line as {prefix} {line}. It is reached from WritePreamble (:293) for documentation, notes and written-down annotations. CFamilyGenerator does not override it.
In C and C++, a backslash at the very end of a line is a line splice. The preprocessor joins it to the next physical line before it strips comments. So a // comment whose text ends in \ swallows the following line of generated code.
A function with Documentation = ["Reads files under C:\\data\\"] generates:
/// Reads files under C:\data\int describe(void)
{
gcc: error: expected identifier or '(' before '{' token
g++: error: expected unqualified-id before '{' token
This affects every documentation line, note and annotation comment in the C and C++ generators. Windows paths and regex examples are the obvious triggers. The other five targets don't splice lines, so they're fine.
This is distinct from #107 (trigraphs inside string literals) and #133 (a line break inside a comment escaping it).
Suggested fix / acceptance criteria
Override WriteComment in CFamilyGenerator so that a comment line ending in \ gets a non-whitespace terminator, for example by appending a character such as .. A trailing space alone doesn't work: gcc still splices it, with only a warning.
Add C and C++ compile tests with a documentation line ending in \, asserting that the generated source compiles and the following declaration survives.
Priority: Medium. A trailing \ in any doc, note or annotation line breaks C/C++ compilation. Windows paths make this easy to hit, but the compile failure is loud.
Activity
matt-edmondson commentedon Oct 5, 2026
Triage
\in any doc, note or annotation line breaks C/C++ compilation. Windows paths make this easy to hit, but the compile failure is loud.CFamilyGenerator/LanguageGeneratorBase.WriteComment. Suggested owner: @matt-edmondson, C-family generators??!,??/etc. are rewritten by trigraphs under -std=c11 ("what??!"printswhat|) #107 (trigraphs) and A documentation or header-comment line containing a line break escapes the comment, and the rest of it is emitted as code in every generator #133 (line break inside a comment). Fix alongside A documentation or header-comment line containing a line break escapes the comment, and the rest of it is emitted as code in every generator #133 if it is still open, since both are comment-escaping issuesGenerated by Claude Code