I know forward declared UDT's can only be used as UDT ptr
but after many years of this limitation exist a workaround may be with the new macro features ?
type _vec3 as vec3 ' forward declare
type vec2
declare constructor(byref x as const single=0.0, byref x as const single=0.0)
declare function xxx as _vec3 ' <--- error 71: Incomplete type
as single x=any,y=any
end type
constructor vec2(byref a as const single, byref b as const single)
x=a:y=b
end constructor
type vec3
declare constructor(byref x as const single=0.0, byref x as const single=0.0, byref z as const single=0.0)
as single x=any,y=any,z=any
end type
constructor vec3(byref a as const single, byref b as const single, byref c as const single)
x=a:y=b:z=c
end constructor
function vec2 . xxx as vec3
vec3(x,x,x)
end function
Last edited by D.J.Peters on May 12, 2021 13:53, edited 1 time in total.
type _vec3 as vec3 ' forward declare
type vec2
declare constructor(byref x as const single=0.0, byref x as const single=0.0)
declare function xxx() byref as _vec3
as single x=any,y=any
end type
constructor vec2(byref a as const single, byref b as const single)
x=a:y=b
end constructor
type vec3
declare constructor(byref x as const single=0.0, byref x as const single=0.0, byref z as const single=0.0)
as single x=any,y=any,z=any
end type
constructor vec3(byref a as const single, byref b as const single, byref c as const single)
x=a:y=b:z=c
end constructor
function vec2.xxx() byref as vec3
static v as vec3
v = vec3(1,2,3)
return v
end function
dim v2 as vec2, v3 as vec3
v3 = v2.xxx() ' <--- function always used like a function returning by value (by copying the returned reference)