62
questions
0
votes
0
answers
61
views
How can i use a shared library in vlang
I have the shared libraries in lib directory.
The library I'd like to load is functions.so and it contains only one function named fib.
I haven't been able to use this library with the information in ...
0
votes
0
answers
32
views
How to call C macro from V/Vlang when macro declares a variable
I am trying to use flecs from V. The flecs header file defines a C macro (ECS_COMPONENT) that in turn defines a new C identifier/variable when expanded.
I've abstracted the problem into a minimal ...
1
vote
1
answer
59
views
How to replace thing in string in vlang?
I making a assembler I have finish the label part but I'm stuck in the replace the label with the address
This is what I get:
module assembler
pub fn assembler(source []string) []string {
mut ...
0
votes
0
answers
34
views
vlang cant find the steamworks librarys
I am currently playing with the integration of C libraries in vlang. I have created a new project with v new projectname and downloaded the steamworks-sdk. For the integration I followed the ...
0
votes
1
answer
128
views
How to create a getch in vlang?
I making a brainfuck interpreter and "," require to get a char without enter but I vlang their is not such of function like getch, the input_character
I have tried embeding C code in Vlang ...
2
votes
1
answer
79
views
Wait for n amount of milliseconds to continue executing the code in V
I am building a web crawler in V to index some URLs. The problem:
I need to limit the amount of requests I send every second, and let’s say I want to send a request every two seconds.
I've used many ...
0
votes
0
answers
40
views
Anonymous union emebed into struct which Equivalent to C in Vlang
Suppose I have a C code where Anonymous union emebed into struct :
struct sname{
union{int a;};
int b;
}
how to write Equivalent code in Vlang ?
I have tried this piece,but it can not ...
0
votes
0
answers
90
views
vlang error: unwrapped Result cannot be used in an infix expression
I have written simple code to overload + operator in v, and unit test for validate if code is working.
// vector.v
module vector
pub struct Vector {
values []int
}
pub fn (v Vector) at(index int)...
0
votes
1
answer
41
views
Getting a git error trying to do "v up" on Linux
I downloaded the zip file for Linux and extracted it to /usr/bin/v. It works fine. But when I run v up it tells me that:
/usr/bin/v> sudo ./v up
Updating V...
From https://github.com/vlang/v
* ...
3
votes
2
answers
264
views
how to declare an array with explicit type in vlang?
I am trying to declare an array like below
arr := [
[0, 0],
[1, 2],
[2, 4],
]
// type: [][]int
but the type I am getting from the inference is [][]int, instead I want to declare [][]float32. ...
0
votes
1
answer
79
views
Error trying to get v.exe to print help information
Is the "help" for the v.exe command not yet implemented? I am getting this:
c:\v>.\v.exe help
error: unknown help topic "default". Use `v help` for usage information.
Known help ...
0
votes
2
answers
200
views
vlang: error: Option function field must be unwrapped first
I'm using the PICOEV lib and got this error: Option function field must be unwrapped first
unsafe { target.cb(event.data.fd, read_events, &pv) }
// target is defines as:
pub struct Target {
pub ...
2
votes
1
answer
407
views
How can i add methods to a struct in vlang?
I am quite new to the v language and i discovered this feature, however it seems like i am doing something wrong.
I have a struct that gathers information in case an error is found somewhere and i'd ...
0
votes
1
answer
164
views
V simple regex use
The following code compiles and runs in V 0.4.0 049d685 without a problem but seems to give incorrect results. I must be doing something wrong, but what is it?
Thanks in advance.
import regex
fn ...
1
vote
1
answer
79
views
How to add a field with a reserved keyword as its name to a structure?
I'm trying to add a field called type to a V structure used for the C interop. It is failing, because type is a keyword too.
The original structure in C:
typedef struct some_s {
int type;
} some_t;
...