decomp.me icon indicating copy to clipboard operation
decomp.me copied to clipboard

Add GHS dotciscxx flag to compile as C++

Open Swiftshine opened this issue 3 weeks ago • 4 comments

With GHS, ccppc and cxppc both determine the file type by its extension. Since the files the scratch uses are called ctx.c and code.c, they're treated as C files. The flag dotciscxx is needed to treat them as C++ files instead.

Swiftshine avatar Dec 08 '25 01:12 Swiftshine

Before this PR is accepted, I think it's better to consider how other platforms handle it? Do they let you choose the language? (I have not used the platform much yet.) Otherwise why even add this flag instead of renaming the files to use the .cpp extension?

aboood40091 avatar Dec 08 '25 02:12 aboood40091

Other platforms also expose the language as a drop-down, which just sets a compiler flag (-x c++ for GCC for instance), so conceptually this solution is okay.

Mc-muffin avatar Dec 08 '25 02:12 Mc-muffin

Is there a flag to explicitly set C (rather than C++)? such that we can leverage LanguageFlagSet behaviour like other compilers?

edit looks like -nodotciscxx might do the trick?

edit2 seems like we arent super consistent given we take the language from the compiler to determine file extension, rather than dynamically from flags (unless im missing something) ?

mkst avatar Dec 08 '25 08:12 mkst

Alternatively, you could use -filetype.[extension] where [extension] is c, cpp, etc. (e.g. -filetype.cpp code.c), though that would have to come directly before the filenames. Is there a way to guarantee that?

Swiftshine avatar Dec 08 '25 10:12 Swiftshine