TYPE Tvector
x
y
z
magnitude
ENDTYPE
FUNCTION vector_new AS Tvector: x,y,z,m
LOCAL result AS Tvector
result.x=x
result.y=y
result.z=z
result.magnitude=m
RETURN result
ENDFUNCTION
FUNCTION add_to_particles_array: a, b, vec AS Tvector
ENDFUNCTION
FUNCTION testf:
add_to_particles_array(1, 1, vector_new(100,100,0,0))
ENDFUNCTION
produces this error...
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.2007.083 - 3D, NET
Wordcount:8 commands
compiling:
C:/DOCUME~1/Dad/LOCALS~1/Temp/glbasic/gpc_temp0.cpp: In function `DGInt __GLBASIC__::testf()':
C:/DOCUME~1/Dad/LOCALS~1/Temp/glbasic/gpc_temp0.cpp:35: error: invalid initialization of non-const reference of type '__GLBASIC__::Tvector&' from a temporary of type '__GLBASIC__::Tvector'
C:/DOCUME~1/Dad/LOCALS~1/Temp/glbasic/gpc_temp0.cpp:29: error: in passing argument 3 of `DGInt __GLBASIC__::add_to_particles_array(DGInt, DGInt, __GLBASIC__::Tvector&)'
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Time: 0.8 sec
Build: 0 succeeded
*** 1 FAILED ***
This is a small section of offending code I've tried to cut out of my own program... I must be doing this wrong?
:s
Why is there no code in the add_to_particles_array function?
it's returning a TYPE by reference. That's bad in your case, faster in most others. I'll have to fix it.
So far, make a LOCAL for the return value of add_to_particle_array, and pass this to the function.
Because it irrelevant to the error I'm afraid.
Code there or not, the error revolves around functions returning types in this situation.
Quote from: GernotFrischit's returning a TYPE by reference. That's bad in your case, faster in most others. I'll have to fix it.
So far, make a LOCAL for the return value of add_to_particle_array, and pass this to the function.
:( OK, Ill add, add that bit of code for now Gernot, thanks for looking into it.
Oh dear. I'm not sure if I can get this working at all. That would require a whole lot of work. However, you get a better error message now.
OK Gernot, thanks for giving it a go and its easy to work around.
Now get to bed its late! :P