From kde-core-devel Thu Sep 27 15:27:28 2001 From: Harri Porten Date: Thu, 27 Sep 2001 15:27:28 +0000 To: kde-core-devel Subject: Re: Reducing the number of conflicts in libraries X-MARC-Message: https://marc.info/?l=kde-core-devel&m=100160457402182 On Mon, 17 Sep 2001, Lubos Lunak wrote: > If you look in qvaluelist.h, you'll notice that all template classes > in this header file have their methods implemented in the class body, which > automatically makes them inline, even if they aren't explicitly marked so. > Some of the methods are quite large and this causes larger executables. > Moreover gcc won't inline some of them (compile with -Winline to see), I didn't get any of these warnings. Strange. Did you have a lower limit set ? > because they are simply too large or for other reasons. Instead inlining > them, an out-of-line copy for them will be created, and such multiple > copies will cause conflicts. All large methods in templates should be moved > out of the class body, so they won't be treated as inline. Also, they > should be either enclosed by an #ifdef block, or they should be > in a separate source file. Since the definitions of non-inline template > methods won't be available, they won't be instantiated anywhere. I "outlined" two larger methods in QMap and looked at the results. An example program just containing a QMap and lots of insert() statements got indeed smaller and compiled faster. Maybe this was just due to compiler optimization, though. libqt got slightly bigger. Is that because the compiler inserted an implementation of e.g. insert() although is wasn't used ? Recompiling Designer as a real world example unfortunately revealed nothing but a slight increase of a few kB in size. Any explanations or suggestions ? I was told that gcc < 3.0 doesn't do any automatic inlining of template member functions at all so one has to be very carefull with a redesign. According to a try of mine it seems to work with gcc 3.0.1, though. Harri.