Error: functions cannot return static array float[4u][4u]

Spacen Jasset spacen at yahoo.co.uk
Thu Feb 21 15:00:51 PST 2008


For this member function:

	float[4][4] toFloatArray4x4()
	{
		float f[4][4];
		return f;
	}

I get:
Error: functions cannot return static array float[4u][4u]

Is it the case that you can't return static arrays? Thinking about this 
it may make some sense. Should I therefore return a float[][] (which 
will always be a float [4]4]. I intend to assign it to a static 
float[4][4] in most cases.

Or rather, should I use an out/ref parameter like so:

toFloatArray4x4(ref float f[4][4])


I was also hoping to define a operator "overload" cast operator, but if 
I can't 'return' static arrays then this will not work.

I can return a struct from a function, why not a static array? I can 
sort of see why this might not work since D objects and types are more 
dynamic oriented than in C and C++ but it seems unnecessary to construct 
an object on the heap ( a float[][] ) just to return it and assign it to 
a static array.

Using:

Digital Mars D Compiler v1.026
Copyright (c) 1999-2008 by Digital Mars written by Walter Bright




More information about the Digitalmars-d-learn mailing list