Skip to content
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

Use more forward declarations #1134

Open
dschwoerer opened this issue Jun 22, 2018 · 1 comment
Open

Use more forward declarations #1134

dschwoerer opened this issue Jun 22, 2018 · 1 comment
Milestone

Comments

@dschwoerer
Copy link
Contributor

Currently many includes could be replaced by forward declarations, e.g. in mesh.hxx:

#include "field2d.hxx"
#include "field3d.hxx"
#include "datafile.hxx"

could be replaced by

class Field2D;
class Field3D;
class Datafile;

That should speed up the compilation of bout, as only the things that are needed get included.

At the same time, we should provide a file that includes ether bout_all - so that projects that use bout can simply include that and get everything they need, rather than including a few files, which then includes everything that gets needed ...

This is going to be a breaking change - so I am not sure this is something we want do ...

Another reason, besides compile performance, is that the current way can be quite horrible to write templates in BOUT++.
I need to forward declare interp_to in newfield, to have it available in the template.
This breaks for the aiolos mesh - as interp_to becomes an inline function - which I cannot copy paste, as I cannot include bout/mesh.hxx - as that results in circular dependencies.
I gave up resolving that, as it seems everything is including everything ... and as mentioned changing that would break a lot of code ...

@ZedThree
Copy link
Member

I rather suspect 5.0 is going have some radical changes to a lot of things, and I'm very happy to break things in major version changes.

I've played with include-what-you-use a few times, which can work out when we only need to forward declare things. Unfortunately, we actually don't include as many headers as we "should" in most places, so accepting everything it says might be a net negative.

A single header to include in physics models would be great, and I think we could do that at the same time as moving all the headers under a proper namespace (as well as maybe using C++ namespace as well).

After 4.2, which is coming I promise, I think we can start breaking things again.

@dschwoerer dschwoerer added this to the BOUT-5.0 milestone Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants