DragonFly users List (threaded) for 2006-12
DragonFly BSD
DragonFly users List (threaded) for 2006-12
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: A c++ puzzle for you gurus


From: Clemens Hintze <ml-dgfly_users@xxxxxxxxxxxxxxxxx>
Date: Tue, 19 Dec 2006 15:09:05 +0100


Am 19.12.2006 um 11:41 schrieb Miguel Sousa Filipe:


Hi,

Hello,


On 12/18/06, walt <wa1ter@myrealbox.com> wrote:

(...)


a header file 'include' a source file before, so I didn't even look at

(...)


Is this practice specific to c++ ?  (If you know of any examples of c
code doing this, please point them out.  Thanks!)

This is not specific to c++, its more specific of aplications that have the source code badly organized, and with twised file dependency chains.

excuse me if I dare to not agree with you here. If using templates in C++ it is not that seldom that one use a .hpp that contains template declarations and includes a .cpp file containing the implementation of those templates.


The reason is to get the declaration (interface) separated from the implementation in different files as usual.

But the C++ compiler has to see the implementation of a template before it is used. Therefore C++ defines a keyword 'export' that allow template definitions reside in other compilation units as theirs declarations for separating purposes.

As not all compiler support 'export' yet, the 'trick' with the .hpp including its .cpp is the only way to separate a template definition from its implementation.

But I have to confess, as I did not looked into mtasker.hpp, I do not know if my babble above is a valid reason for mtasker.hpp including mtasker.cpp, or if it is really a sign of bad source code organization. I only want to point out, that it isn't a pattern for bad code organization!

So, it's possible to have "bad" organization like that in C too.

For C sources, I would tend to agree with you, as I do not see any reason for a header to include a .c source.



Best regards, Clemens.



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]