What do you think about notus ?
May be this two libraries could be merged to something powerful :)
What about using boost::polymorphic_cast which retranslated to dynamic_cast on debug and static_cast on release ?
So there will be no require fo RTTI for release and the code will be smaller.
1. I took a look at notus a while ago -- and it seems just too generic for me. Perhaps that has changed, I could take a look when I have the time
2. I'm using dynamic_cast, since you could choose to derive from multiple classes at once -- and you can already see quite a few window classes that do multiple inheritance.
In this case, dynamic_cast is a must.
> and it seems just too generic for me
1. That's why win32gui has future :)
2. Maybe there is some way to compile without RTTI ?
The reason for this is that the names which are created with RTTI take too much space in the executable and there are names of the classes in the executable.
Anyway the executable can be compressed very well :)
1. Thanks :)
2. To tell you the truth, I have never tried. But due to the problems I had a while ago, I woudn't recommend it.
In fact, a while ago, I did avoid dynamic_cast. However, some applications crashed -- debugged it, and I realized this was the cause -- dynamic_cast is a must for non-trivial apps.
2. Maybe dynamic_cast can be avoided by using virtual functions ?
Or for instance using self RTTI, e.g. like MFC, or using GUID for each class which wants to use 'RTTI'.
It's not that I do not love RTTI.
I do not love that a quater of executable is used not by code but by names for RTII :)
dynamic_cast can't be avoided -- as said, I tried.
As for the RTTI taking 1/4th of the executable, I've never looked at the space needed by RTTI, but I certainly hope it's not that much!
>As for the RTTI taking 1/4th of the executable, I've never looked at the space needed by RTTI, but I certainly hope it's not that much!
I hope too.
But take a look for instance at cross builder.
I have found that a half MB is taken by names of exception and RTTI.
It's a quater of the whole executable. :)
Please take a look about this.
I gues dynamic_cast problem can be solved without the RTTI.
By the way this is the reason why the compressor can compress executable from 2Mb to 300kb ;)
The custom RTTI is fairly easy to implement in non-generic legacy libraries like MFC (well, it doesn't even use the multiple inheritance). You can put anything you like inside the .lib files and enjoy using only class interfaces without caring much about the internal details.
However, the whole thing is different with the generic libraries - the heavy template usage force your own code to use the same conventions and policies as the library's internal achitecture. That means basically that all users are FORCED to use the whatever RTTI implementation but not the standard C++ one.
(Not to mention that the custom RTTI is also a source of hundreds of ponential bugs, and this is all just to reduce the executable size!)
As to the RTTI overhead - I agree that sometimes this is a pain in the behind, but not really a serious issue considering the compression ratio for the executables. You may also use the mighty UPX compressor for deploying the small utilities.
I certainly agree.
As for compression, if you make a setup kit, you can use NSIS (http://sourceforge.net/projects/nsis) -- which also compresses your files quite heavily.
The point was to exclude use of dynamic_cast so the RTTI will be the option for the application.
As I see there is no simple solution for this.
It just says that if you develop with win32gui you should always compress the executable ;)