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

C Builder error #21026

Closed
Eliyaan opened this issue Mar 14, 2024 · 7 comments
Closed

C Builder error #21026

Eliyaan opened this issue Mar 14, 2024 · 7 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@Eliyaan
Copy link
Contributor

Eliyaan commented Mar 14, 2024

Describe the bug

The program outputs a C builder error.

Reproduction Steps

module main

#flag -I /lib64/libuvc/include/
#flag -luvc
#include <libuvc/libuvc.h>

@[typedef]
struct C.uvc_frame{
}

type FnFrameCB = fn (frame &C.uvc_frame)


fn main() {
	println("Hello?")

}

Expected Behavior

It not to output a C builder error.

Current Behavior

/tmp/v_1000/main.01HRZ3YKKMZ1PNX2QP72SFE0MN.tmp.c:939: error: ',' expected (got "*")
builder error: 
==================
C error. This should never happen.

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

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Possible Solution

No response

Additional Information/Context

(using libuvc)

V version

V 0.4.4 673a2f4.0a9d1f9

Environment details (OS name and version, etc.)

V full version: V 0.4.4 673a2f4.0a9d1f9
OS: linux, Linux version 6.6.13-200.fc39.x86_64 (mockbuild@72f11b2996ed4699b0f705186172808f) (gcc (GCC) 13.2.1 20231205 (Red Hat 13.2.1-6), GNU ld version 2.40-13.fc39) #1 SMP PREEMPT_DYNAMIC Sat Jan 20 18:03:28 UTC 2024
Processor: 4 cpus, 64bit, little endian, Intel(R) Pentium(R) Gold 7505 @ 2.00GHz

getwd: /home/nopana/projects/cnn_dataset/movenet
vexe: /home/nopana/v/v
vexe mtime: 2024-03-14 18:35:56

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

Git version: git version 2.43.0
Git vroot status: weekly.2024.09-60-g0a9d1f9d
.git/config present: true

CC version: cc (GCC) 13.2.1 20231205 (Red Hat 13.2.1-6)
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@Eliyaan Eliyaan added the Bug This tag is applied to issues which reports bugs. label Mar 14, 2024
@spytheman
Copy link
Member

#flag -luvc
#include <libuvc/libuvc.h>

@[typedef]
struct C.uvc_frame_t {
}

type FnFrameCB = fn (frame &C.uvc_frame_t)

fn main() {
	println('Hello?')
}

This compiles cleanly for me, after I installed https://github.com/libuvc/libuvc .

Note the C.uvc_frame_t, if you want to use @[typedef].

@spytheman
Copy link
Member

On the C side:

typedef struct uvc_frame {
...
} uvc_frame_t;

(from https://github.com/libuvc/libuvc/blob/master/include/libuvc/libuvc.h#L455)

@felipensp
Copy link
Member

Can be closed @Eliyaan ?

@Eliyaan Eliyaan closed this as completed Mar 29, 2024
@JalonSolov
Copy link
Contributor

No, it shouldn't be closed, yet, since the original issue is still a problem.

Having a workaround is good, but V should always catch and report errors (if it can), instead of letting the C compiler find them.

In this case, V should probably have reported that the typedef struct name didn't end in _t, if that's something it can figure out.

@JalonSolov JalonSolov reopened this Mar 29, 2024
@felipensp
Copy link
Member

Afaik this is not something the V can figure out.

@JalonSolov
Copy link
Contributor

It can figure out that the C. name doesn't end with _t but @[typedef] was used.

However, I don't know if that's a universal rule or not. If not, then yes, this should simply be closed. Otherwise, this check should be added.

@Eliyaan
Copy link
Contributor Author

Eliyaan commented Apr 15, 2024

From the C I can see (not much) it is not an universal rule, so I'm closing the issue.

@Eliyaan Eliyaan closed this as completed Apr 15, 2024
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.
Projects
None yet
Development

No branches or pull requests

4 participants