12.6.7.6 CPP0005 - Undeclared Marshalling Value Type Variable

Description

Extern classes and enums annotated with cpp.ValueType can live on the stack and are considered not nullable, to support undeclared local variables this would necessitate the underlying native type to have a default constructor which is might not have. Due to this, undeclared local variables of marshalling value types are not supported, doing so generates this error.

Examples

The following example generates CPP0005.

@:semantics(value)
@:cpp.ValueType
extern class Foo {
    function new():Void;
}

function main() {
    var f : Foo; // CPP0005

    if (Math.random() > 0.5) {
        f = new Foo();
    }
}