Skip to content

Commit 3059ff0

Browse files
authored
fix: cpp-generator escapes names stdin, stdout, stderr (#622)
msvc treats stdin, stdout, stderr as keywords (or maybe they are macros?). We need to escape these by adding a underscore "_", as we do for otherkeywords.
1 parent e48d149 commit 3059ff0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

schema_salad/cpp_codegen.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,18 @@
3333

3434
def replaceKeywords(s: str) -> str:
3535
"""Rename keywords that are reserved in C++."""
36-
if s in ("class", "enum", "int", "long", "float", "double", "default"):
36+
if s in (
37+
"class",
38+
"enum",
39+
"int",
40+
"long",
41+
"float",
42+
"double",
43+
"default",
44+
"stdin",
45+
"stdout",
46+
"stderr",
47+
):
3748
s = s + "_"
3849
return s
3950

0 commit comments

Comments
 (0)