v
v copied to clipboard
Aliasing of a C Struct not working unless by adding a typedef attribute
Describe the bug
I tried to alias a C struct to avoid typing C.My_Struct each time. I have errors during compilation
Expected Behavior
I expected my program to compile normally
Current Behavior
The compiler shows me this error :
C:\Users\USER\AppData\Local\Temp\v_0\main2.3589850650208729523.tmp.c: In function 'main__main':
C:\Users\USER\AppData\Local\Temp\v_0\main2.3589850650208729523.tmp.c:12338:99: error: 'tilengine__TLN_Affine' {aka 'struct TLN_Affine'} has no member named 'angle'
12338 | tilengine__TLN_Affine* affine = ((tilengine__TLN_Affine*)memdup(&(tilengine__TLN_Affine){.angle = 10,.dx = 1,.dy = 1,.sx = 1,.sy = 1,}, sizeof(tilengine__TLN_Affine)));
| ^~~~~
C:\Users\USER\AppData\Local\Temp\v_0\main2.3589850650208729523.tmp.c:12338:107: warning: excess elements in struct initializer
12338 | tilengine__TLN_Affine* affine = ((tilengine__TLN_Affine*)memdup(&(tilengine__TLN_Affine){.angle = 10,.dx = 1,.dy = 1,.sx = 1,.sy = 1,}, sizeof(tilengine__TLN_Affine)));
| ^~
C:\Users\USER\AppData\Local\Temp\v_0\main2.3589850650208729523.tmp.c:12338:107: note: (near initialization for '(anonymous)')
C:\Users\USER\AppData\Local\Temp\v_0\main2.3589850650208729523.tmp.c:12338:111: error: 'tilengine__TLN_Affine' {aka 'struct TLN_Affine'} has no member named 'dx'
12338 | tilengine__TLN_Affine* affine = ((tilengine__TLN_Affine*)memdup(&(tilengine__TLN_Affine){.angle = 10,.dx = 1,.dy = 1,.sx = 1,.sy = 1,}, sizeof(tilengine__TLN_Affine)));
| ^~
C:\Users\USER\AppData\Local\Temp\v_0\main2.3589850650208729523.tmp.c:12338:116: warning: excess elements in struct initializer
...
Reproduction Steps
I used this command : C:\V\v.exe -cc gcc run main2.v
Here is an example of my program : main2.zip
Possible Solution
adding [typedef] attribute to a C struct fix the problem
Additional Information/Context
No response
V version
V 0.3.2 5aad0db
Environment details (OS name and version, etc.)
OS: windows, Microsoft Windows 11 Home v22621 64-bit Processor: 8 cpus, 64bit, little endian, CC version: cc (Rev7, Built by MSYS2 project) 12.2.0
getwd: C:\Users\USER\Documents\programmation\testV vmodules: C:\Users\USER.vmodules vroot: C:\v vexe: C:\v\v.exe vexe mtime: 2023-01-24 14:29:41 is vroot writable: true is vmodules writable: true V full version: V 0.3.2 f71572a.5aad0db
Git version: git version 2.35.1.windows.2 Git vroot status: weekly.2023.03-61-g5aad0db0 .git/config present: true thirdparty/tcc: N/A