How to get nogc to work with manual memory allocation

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 24 02:29:53 PDT 2014


On 2014-08-24 10:03, Bienlein wrote:

> I have omitted the code for the TestClass class to save space. Problem
> is that the compiler outputs this:
>
> Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' cannot call
> non- at nogc function 'core.exception.onOutOfMemoryError'
> Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' cannot call
> non- at nogc function 'std.conv.emplace!(TestClass, ).emplace'
> Error: @nogc function 'main.nogcDel!(TestClass).nogcDel' cannot call
> non- at nogc function 'object.destroy!(TestClass).destroy'
>
> Is there a way to get around this?

@nogc is a very new attribute. The runtime and standard library have not 
been properly annotated with this attribute yet.

As a workaround you could try copy implementation of these functions to 
you're own code and annotate them as appropriate.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list