RFC: Organising .inline.hpp and .hpp includes
David Holmes
david.holmes at oracle.com
Thu Aug 11 07:31:46 UTC 2016
I'm trying to tackle the incorrect inclusion of .hpp files instead of
.inline.hpp starting with the use of atomic.inline.hpp ref:
https://bugs.openjdk.java.net/browse/JDK-8157907
The basic rules would seem to be:
If class Foo has inline methods that need to call the inline Atomic
methods then:
- Those methods should be defined in foo.inline.hpp
inline void Foo::a() { /* do stuff with atomics */ }
- foo.hpp declares those methods:
inline void a();
- foo.inline.hpp includes foo.hpp
- foo.inline.hpp includes atomic.inline.hpp
- foo.cpp includes foo.inline.hpp
Do have agreement so far?
Now suppose we have class Bar which uses Foo.
- bar.cpp should include foo.inline.hpp
- If bar.hpp only references Foo but doesn't need to see a full
definition then bar.hpp can forward declare Foo
- If bar.hpp defines inline methods that require full access to Foo then
either:
a) bar.hpp includes foo.inline.hpp; or
b) The inline functions of Bar are themselves moved to bar.inline.hpp
which includes foo.inline.hpp
I think there was general opinion that (a) is undesirable, and that (b)
is preferable - is that right?
What I am finding is that the fan out of applying (b) is rather large -
to the point where we may end up having x.hpp, x.inline.hpp and x.cpp
variants for very many x!
Just to add another dimension to this, what should precompiled.hpp
include? I would assume the .inline.hpp files right?
Thanks,
David
More information about the hotspot-dev
mailing list