problems with Objective-C++
problems with Objective-C++
- Subject: problems with Objective-C++
- From: "Simson L.Garfinkel" <email@hidden>
- Date: Mon, 21 Jan 2002 15:47:06 -0500
It has been commented on this mailing list that Objective-C++ takes 20x
longer to compile a file than Objective-C or C++, but nobody has ever
said why or what to do about it.
I am working on a large project that involves Objective-C and C++. I had
wanted to use Objective-C++. Changing the extension of an Objective-C
file from .m to .mm I saw the size of each .o file balloon from
approximately 200k to 6M! I saw compile times go from 2-3 seconds to
30-60 seconds!
This was unacceptable.
So what I have done is I have tried to segregate the cross between the
Objective-C world and the C++ world to as few areas as possible. right
now it is in 2 classes. These are the only two that are .mm files; the
rest are .m files. These are the two classes that have C++ objects in
their instance variables. There is no problem messaging these classes
from .m files, so it's a huge win, really. If other methods need to call
C++ classes but not have C++ objects as instance variables, I put all of
those methods into a separate .mm file that is done as a category.
All of this works, but it is kind of difficult.