-
Notifications
You must be signed in to change notification settings - Fork 251
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
generated hpp file is not #included by generated cpp file [BUG] #1145
Comments
Although I suspect that my idea of how it works is wrong, because it would mean that if multiple cpp2 files included a .h2 file, the generated cpp files would each contain all the definitions in the generated hpp file; so I'm not sure what is meant to happen. However, in the current design it seems that only one cpp2 file can be used in an app, so the system is workable if that single cpp2 file gives rise to a single cpp file in which all the hpp files are #included. |
Revised patch: add a check that the current output file isn't a .h file, emit an explanatory comment, and move the code after emitting function definitions:
|
i believe this is a duplicate of #594 |
The current system for creating and using classes outside the main cpp2 file is to write a file with the extension
.h2
containing the classes that are needed, then put#include "myheader.h2"
at the top of the cpp2 file. The idea is that#include "myheader.h2"
in the cpp2 file into two statements in the generated cpp file:#include "myheader.h"
at the top, and ...#include "myheader.hpp"
later on.Steps 1 and 2 work, but step 3 does not. No
#include "myheader.hpp"
statement is added by cppfront to the generated cpp file.Suggested fix (works for me, but I have not analysed the code and the fix may not be correct in all circumstances): move the statement
printer.print_extra( hpp_includes );
into_cpp1.hpp
out of its conditional block. Here is a patch:The text was updated successfully, but these errors were encountered: