-
-
Notifications
You must be signed in to change notification settings - Fork 575
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
Forward declarations of godot-cpp classes. #1273
Comments
I think that there's no bother to have to forward declare what you need, having one massive file to forward declare that you need to make sure contains everything seems unnecessary (and forces you to rebuild you entire plugin every time something changes in that file) Just like you just include what you need, just forward declare what you need, programming with intentionality is important IMO |
That is certainly a valid point of view. I think it would be beneficial to add a file with forward declarations to godot-cpp, rather than each individual programmer create their own file. It saves time, avoids errors, remains up-to-date as godot-cpp evolves, all the usual arguments for including anything in a library. Some forward declarations can be non-trivial, e.g. template forward declarations. E.g. there is
For me this is a relatively rare event, I'll take it. Whereas speed of compilation during the edit-compile-bugfix cycle is important, because I may do that many times per day. Forward declarations reduce compilation time. I have a high regard for the It seems that generating the forward declarations header file can (partially?) be done from the JSON API file, is that correct? |
I don't mean anyone should make their own file, simply that people should use forward declarations only where they are needed, which IMHO is the appropriate approach
Me too about the library, but I'm not sure those are intended for the end users but for internal support, which doesn't apply here |
For the most part, I agree with @AThousandShips, and think that making your own forward declarations for the classes you're using is just a normal part of using C++. However, if making headers of forward declarations is becoming common practice for C++ libraries (I wasn't previously aware of this, but Googling, I can see PR's welcome, as always :-) |
I guess you are thinking of me when it comes to opening a PR. I looked at it, my brain is definitely not wired correctly for Python. But who knows, I might have a go at it. |
I think having a file for every Godot class with a single forward declaration in them is pointless. It doesn't help compared to a single line |
Assuming I understood the idea correctly, I thought it was to have a single header file (ex |
Godot version
v4.1.1.stable.custom_build [bd6af8e0e]
godot-cpp version
4.1 4eed2d7
System information
Godot v4.1.1.stable (bd6af8e0e) - Linux Mint 21.2 (Victoria) - Vulkan (Forward+) - integrated Intel(R) Graphics (RPL-P) () - 13th Gen Intel(R) Core(TM) i7-1360P (16 Threads)
Issue description
When declaring, in a header file, a class member that is a pointer to a godot class, e.g.
::godot::Node * pointerToNode
, I need to either#include <godot_cpp/classes/node.hpp>
or add something likeI prefer the latter, because the
#include
slows down compilation. A godot header file with forward declarations for all godot classes would be nice.I previously asked a question here: https://godotforums.org/d/36916-c-forward-declarations-for-godot-classes
Steps to reproduce
I hope you don't mind asking for this enhancement here, I thought of adding it to the godot repository itself, but it seems to me this issue is very much related to godot-cpp. Please let me know if I should file this issue elsewhere.
Minimal reproduction project
Any project will do.
The text was updated successfully, but these errors were encountered: