Inkscape::UI::Dialog::PanelDialogBase .cpp and .h file
Hi,
I was working filling the wiki about User Interface.
Is it normal that the file src/ui/dialog/panel-dialog.h does not have a .cpp? This file contains prototypes and source code of all functions of the class Inkscape::UI::Dialog::PanelDialogBase.
For clarity and compilation optimisation, would it be better to break it in a .cpp and .h files ?
Thanks,
On Thursday, December 15, 2011 02:36:39 pm Romain de Bossoreille wrote:
Hi,
I was working filling the wiki about User Interface.
Is it normal that the file src/ui/dialog/panel-dialog.h does not have a .cpp? This file contains prototypes and source code of all functions of the class Inkscape::UI::Dialog::PanelDialogBase.
For clarity and compilation optimisation, would it be better to break it in a .cpp and .h files ?
Thanks,
It used to be the case that gcc required template classes to be implemented in a single translation unit (i.e., in the header) because dealing with templates in the linker is tricky (though possible -- I think the SGI MIPS compiler was able to handle it). I think that gcc still has this requirement, and that that is why the code is factored this way.
--Mark
Mark,
Yes there are templates, but also at least 3 non-template functions:
void PanelDialogBase::_propagateDocumentReplaced() void PanelDialogBase::_propagateDesktopActivated() void PanelDialogBase::_propagateDesktopDeactivated()
As far as I can tell templates still need to be implemented in the .h, there are some workarounds where developpers are placing them in a .cpp and then put a #include "XXXXX.cpp" in the .h but that's not very good style programming.
participants (2)
-
Mark Voorhies
-
Romain de Bossoreille