[Interest] Three-file modules vs. moc
Bernhard Lindner
private at bernhard-lindner.de
Thu Aug 27 15:58:01 CEST 2020
Hi!
> I wonder how clients of the class declared in the .hpp file can use that class at all.
> Unless I am missing something, they won’t be able to (at least not in the general case)
> unless they also include the .inl file.
Depends from what part of the module API you want to use. E.g. if only macros or
types/classes are need, including the .hpp is faster and sufficient. This means a .hpp
will typically include other .hpp.
If you want to call functions you will include .inl. This means a .cpp or a .inl will
typically include other .inl.
> Wouldn’t it be simplier to #include the inl file in the hpp file? That way you still
> have separation of declaration and definition on a file-level, but don’t expose users of
> your C++ headers (including moc) to your way of organizing things.
Tried that before. Then it turned out that on the .inl level a mutual dependency lock can
happen (similar to what you get if normal hpp/cpp modules try to include include eachother
without using forward declarations). Only the two-level-inclusion as described above
reliably solves all mutual inclusion issues.
--
Best Regards,
Bernhard Lindner
More information about the Interest
mailing list