-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] cpp1 module declaration must be at beginning of generated .cpp file #1358
Comments
IMHO, I don't recommend using mainline cppfront if you're going to make significant use of modules. You're much better off using Johel's branch that has decent module support (https://github.com/JohelEGP/cppfront, branch cpp_modules). I did most of Advent of Code 2024 with that (https://github.com/threeifbyair/advent2024) and although it wasn't perfect, it did work. |
Thanks for the pointer, I will try that. We have switched to C++ modules in a ~100 KLOC project using C++20 (MSVC on Windows). |
I have read the rationale of Herb for closing #569 in 2023, but cppfront is currently producing wrong cpp1 code when a mixed syntax input .cpp2 file contains the As long as cppfront accepts mixed input I think it should at least correctly treat valid cpp1 code that is mixed with cpp2 code. If/when cppfront should accept the |
I can confirm that with commit dacf98c of https://github.com/JohelEGP/cppfront (branch cpp_modules) this bug here doesn't exist. The cpp1 output file has a correct global module fragment. Declarations and includes are at the right places for example with this .cpp2 input file:
the output file is (correct):
|
If the (mixed) .cpp2 input-file begins with a C++20 module declaration, e.g.
module foo;
the generated .cpp file is not valid C++20.
The file begins with various #includes and declarations, followed by the invalidly placed module declaration.
Also, #include's should be placed in the global module fragment.
The text was updated successfully, but these errors were encountered: