Re: C++ templates?
Re: C++ templates?
- Subject: Re: C++ templates?
- From: Allan Odgaard <email@hidden>
- Date: Thu, 15 Apr 2004 21:28:44 +0200
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 :)
** Cocoa FAQ: <
http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
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.