mirror of
https://github.com/vlang/v.git
synced 2025-08-04 02:07:28 -04:00
21 lines
408 B
V
21 lines
408 B
V
module test
|
|
|
|
// Note: compile this with `v -d no_backtrace -shared test.v`
|
|
import math
|
|
|
|
@[export: 'square']
|
|
fn square(i int) int {
|
|
return i * i
|
|
}
|
|
|
|
@[export: 'sqrt_of_sum_of_squares']
|
|
fn sqrt_of_sum_of_squares(x f64, y f64) f64 {
|
|
return math.sqrt(x * x + y * y)
|
|
}
|
|
|
|
// you do not have to use the same name in the export attribute
|
|
@[export: 'process_v_string']
|
|
fn work(s string) string {
|
|
return 'v ${s} v'
|
|
}
|