Strange Error when compiling StructureUnion in C-Backend
Posted: Thu Aug 15, 2024 4:41 pm
I have a strange Error when compiling a Structure Union Construction in C-Backend.
In ASM-Backend it is working perfect!
I use actual PB 6.11
IDE build on 06/06/2024 [09:41] by Fred
Branch: v6.11 Revision: 5a52d0b14a87
THIS IS THE ERROR MESSAGE
---------------------------
PureBasic - Assembler error
---------------------------
error: incompatible types when initializing type 'float' using type 'vecfXs_tvector' {aka 'struct vecfXs_tvector'}
673 | vecfXs_tmatrix v_matrix={0};
| ^~~~~~~~~~~~~~
purebasic.c: In function 'draw3dXf__draw3dpoint':
purebasic.c:693:30: warning: ex
---------------------------
I figured out that the problem is the initialisation of a var.TVector
I created a test code what shows the situation but in the test code tere is no problem!
Until now I'm not able to locate the problem. I checked C-Output but I could not find anything.
Then I reinstalled PB but same problem (and I killed my Show C-Output)
To see the Error you have to download the orignal Project here:
https://github.com/Maagic7/PureBasicFra ... main/Demos
Draw3D_with_VECf.zip
It is a modification from STARGATEs Draw3D to test my Vector Module
Here is the test code what shows the situation but not the error.
I hope anyone of you is able to locate the problem!
Many thanks
In ASM-Backend it is working perfect!
I use actual PB 6.11
IDE build on 06/06/2024 [09:41] by Fred
Branch: v6.11 Revision: 5a52d0b14a87
THIS IS THE ERROR MESSAGE
---------------------------
PureBasic - Assembler error
---------------------------
error: incompatible types when initializing type 'float' using type 'vecfXs_tvector' {aka 'struct vecfXs_tvector'}
673 | vecfXs_tmatrix v_matrix={0};
| ^~~~~~~~~~~~~~
purebasic.c: In function 'draw3dXf__draw3dpoint':
purebasic.c:693:30: warning: ex
---------------------------
I figured out that the problem is the initialisation of a var.TVector
Code: Select all
Procedure _Draw3DPoint(*Vertex.TDraw3D_Vertex)
;TODO! Find the Problem in the Draw3D Project in C-Backend
; This line creates the Compiler Error in C-Bakcen but only in the real projct not in this demo!
Protected Projection.TVector
EndProcedure
Until now I'm not able to locate the problem. I checked C-Output but I could not find anything.
Then I reinstalled PB but same problem (and I killed my Show C-Output)
To see the Error you have to download the orignal Project here:
https://github.com/Maagic7/PureBasicFra ... main/Demos
Draw3D_with_VECf.zip
It is a modification from STARGATEs Draw3D to test my Vector Module
Here is the test code what shows the situation but not the error.
Code: Select all
DeclareModule Vecf
EnableExplicit
Structure TPoint2D Align 4 ; to be sure it will be 4Byte Aligned at x64
X.f
Y.f
EndStructure
Structure TVector Align 4 ; Single precicion Vector [16 Bytes / 128 Bit]
StructureUnion
v.f[0] ; virutal Array v[0]=x, v[1]=y, v[2]=z, v[3]=w
Pt2D.TPoint2D[0]
EndStructureUnion
x.f
y.f
z.f
w.f
EndStructure
Debug "SyzeOf(VECf::TVector) = " + SizeOf(TVector)
; Single precicion Matrix
Structure TMatrix Align 4 ; to be sure it will be 4Byte Aligned at x64
StructureUnion
v.TVector[0] ; Vector interpretation of the Matrix Structure
Pt2D.TPoint2D[0]
EndStructureUnion
m11.f : m12.f : m13.f : m14.f
m21.f : m22.f : m23.f : m24.f
m31.f : m32.f : m33.f : m34.f
m41.f : m42.f : m43.f : m44.f
EndStructure
Declare.i Vector_Set(*OUT.TVector, X.f=0.0, Y.f=0.0, Z.f=0.0, W.f=0.0)
EndDeclareModule
Module Vecf
Procedure.i Vector_Set(*OUT.TVector, X.f=0.0, Y.f=0.0, Z.f=0.0, W.f=0.0)
With *OUT
\x = X
\y = Y
\z = Z
\w = W
EndWith
EndProcedure
EndModule
; ----------------------------------------------------------------------
DeclareModule Draw3D
EnableExplicit
Declare DrawPoint3D(X.f, Y.f, Z.f, Color.q)
EndDeclareModule
Module Draw3D
; Zeichnet einen Punkt in die Szene
UseModule Vecf
Structure TColor4
Alpha.f ; Intensität [0.0, 1.0]
Blue.f ; Blau [0.0, Intensität]
Green.f ; Grün [0.0, Intensität]
Red.f ; Rot [0.0, Intensität]
EndStructure
Structure TDraw3D_Vertex Extends TVector
Color.TColor4 ; Farbe
EndStructure
Procedure _Draw3DPoint(*Vertex.TDraw3D_Vertex)
;TODO! Find the Problem in the Draw3D Project in C-Backend
; This line creates the Compiler Error in C-Bakcen but only in the real projct not in this demo!
Protected Projection.TVector
; Protected Distance.f
; Protected X.i, Y.i
; Protected Visible.f
; Protected *Pixel.TDraw3D_Pixel
;
; _Draw3D_Projection(Projection, *Vertex)
;
; Draw3DInclude\CurrentColor[0] = *Vertex\Color
; X = Projection\X
; Y = Projection\Y
; If X >= 0 And (X <= Draw3DInclude\MaxX) And (Y >= 0) And (Y <= Draw3DInclude\MaxX)
; *Pixel = _Draw3D_AddPixel(X, Y, *Vertex\Z)
; If *Pixel
; _ColorMix(*Pixel\Color, 1.0)
; EndIf
; EndIf
EndProcedure
Procedure DrawPoint3D(X.f, Y.f, Z.f, Color.q)
Protected Vertex.TDraw3D_Vertex
Vector_Set(Vertex, X, Y, Z)
; _SetColor(Vertex\Color, Color)
; _Draw3D_Rotate(Vertex, Draw3DInclude\Orientation)
; Vector_Sub(Vertex, Vertex, Draw3DInclude\Position); V4_Subtract(Vertex, Draw3DInclude\Position)
_Draw3DPoint(Vertex)
EndProcedure
EndModule
Draw3D::DrawPoint3D(5,10,15, RGB(255,0,0))
MessageRequester("C-Backend Structure Union Test", "Done")
Many thanks