Re: C++ templates?
Re: C++ templates?
- Subject: Re: C++ templates?
- From: John Stiles <email@hidden>
- Date: Thu, 15 Apr 2004 14:11:41 -0700
On Apr 15, 2004, at 12:28 PM, Allan Odgaard wrote:
On 15. Apr 2004, at 20:04, David Piasecki wrote:
I tried creating a C++ template for my Cocoa application in XCode. It
compiles fine, but I get a runtime error which crashes my application,
even if all I do is create the object. Source included below...
Correct me if I am wrong, but your code-snip did not show any usage of
the template? Do you use ObjectiveC objects with this template? and
what do you have to do at runtime to provoke the crash?
That said, there does seem to be some template-related problems with
ObjectiveC++ resulting in both compile-time (internal compiler error)
and run-time problems. For the latter though my problem has so far
been limited to calling ObjC methods in templated code, e.g. something
like this:
// main.mm
#import <Cocoa/Cocoa.h>
template <typename T> void dummy ()
{
[NSFont fontWithName:@"Monaco" size:12.0f];
}
int main (int argc, char const* argv[])
{
[NSAutoreleasePool new];
dummy<int>();
return 0;
}
Will crash (at runtime) with a segmentation error -- so generally I
avoid having ObjC code in templated code :)
Weird. I use templates all the time without problems. Then again, I
guess I'm in the minority here, but I use CodeWarrior :)
gcc runs too slow and the generated code makes me go ick.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.