Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated C has typedefs in the wrong order #19367

Closed
jcweaver997 opened this issue Sep 16, 2023 · 1 comment · Fixed by #20638
Closed

Generated C has typedefs in the wrong order #19367

jcweaver997 opened this issue Sep 16, 2023 · 1 comment · Fixed by #20638
Labels
Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@jcweaver997
Copy link

jcweaver997 commented Sep 16, 2023

Describe the bug

I have an auto translated wrapper that compiles successfully when in the main module, but does not compile correctly when its in its own module.

Reproduction Steps

Using the attached module, and the following code:

module main

import gdi

[export: 'hello_extension_entry']
pub fn hello_extension_entry(gpaddr gdi.GDExtensionInterfaceGetProcAddress, clp gdi.GDExtensionClassLibraryPtr, mut gdinit gdi.GDExtensionInitialization) gdi.GDExtensionBool {
    return 1
}

Its meant to be compiled as a shared library: v -shared .

Expected Behavior

Successful compile

Current Behavior

When compiling, it gives the following error:

v -no-parallel -shared .    
==================
c:/users/jcwea/documents/git/v/thirdparty/tcc/include/winapi/synchapi.h:167: warning: CreateMutex redefined
C:/Users/jcwea/AppData/Local/Temp/v_0/jvnet.4895371472969035013.tmp.so.c:2109: error: identifier expected
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

When checking the tmp c file on line 2109, it shows it using gdi__GDExtensionInterfaceFunctionPtr, which is defined on line 2172:
line 2109:
image
line 2172:
image

Possible Solution

typedefs could be checked for types it uses, and if that type hasn't been defined yet, define it first

Additional Information/Context

This is for GDExtension 4.1 for Godot. I plan on fully developing and publishing this as an open source library once its in a usable state, allowing users to use V for game development in Godot

V version

V 0.4.1 bb95a27

Environment details (OS name and version, etc.)

Tested on Windows:

v doctor
V full version: V 0.4.1 d93488b.bb95a27
OS: windows, Microsoft Windows 11 Pro Insider Preview v23541 64-bit
Processor: 24 cpus, 64bit, little endian, 

getwd: C:\Users\jcwea\Documents\git\jvnet
vexe: C:\Users\jcwea\Documents\git\v\v.exe
vexe mtime: 2023-09-16 16:23:44

vroot: OK, value: C:\Users\jcwea\Documents\git\v
VMODULES: OK, value: C:\Users\jcwea\.vmodules
VTMP: OK, value: C:\Users\jcwea\AppData\Local\Temp\v_0

Git version: git version 2.40.0.windows.1
Git vroot status: weekly.2023.37-22-gbb95a276-dirty
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 e90c2620

And WSL

v doctor
V full version: V 0.4.1 bfaa3de.bb95a27
OS: linux, Linux version 5.15.90.4-microsoft-standard-WSL2 (root@4b885f886b45) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37) #1 SMP Tue Jul 18 21:28:32 UTC 2023 (WSL 2)
Processor: 24 cpus, 64bit, little endian, 13th Gen Intel(R) Core(TM) i7-13700K

getwd: /mnt/c/Users/jcwea/Documents/git/jvnet
vexe: /home/jc/git/v/v
vexe mtime: 2023-09-16 16:25:34

vroot: OK, value: /home/jc/git/v
VMODULES: OK, value: /home/jc/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.42.0
Git vroot status: weekly.2023.32-234-gbb95a276
.git/config present: true

CC version: cc (GCC) 13.2.1 20230801
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

Important

You can vote for this issue using the 👍 reaction. More votes increase the issue's priority
for developers.

Take into account that only the 👍 reaction counts as a vote.
Only reactions to the issue itself will be counted as votes, not comments.

@jcweaver997 jcweaver997 added the Bug This tag is applied to issues which reports bugs. label Sep 16, 2023
@ArtemkaKun ArtemkaKun added the Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. label Sep 17, 2023
@pierrec
Copy link
Contributor

pierrec commented Jan 24, 2024

@jcweaver997 Now awaiting for the Godot V extension :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants