[Interest] Three-file modules vs. moc

Volker Hilsheimer volker.hilsheimer at qt.io
Thu Aug 27 15:30:39 CEST 2020


> On 27 Aug 2020, at 14:42, Bernhard Lindner <private at bernhard-lindner.de> wrote:
> 
> Hi!
> 
>> Can you make an example of your structure (what's exactly in each of the 
>> three files)? It's not entirely clear.
> 
> Ok, I attached an example of a module containing some pseudo code. Please tell me if you
> need more information.
> 
>> You might also use a custom extra compiler -- that still invokes moc, 
>> but for each foo.h also tells moc to include foo.inl, bar.h -> bar.inl, 
>> and so on...
> 
> Hm, I see. Has something like that been done before, is there code I could reuse?

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.

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.


Volker



More information about the Interest mailing list