1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

make $if work with includes: skip the body if the target is different

This commit is contained in:
Alexander Medvednikov
2019-10-12 00:54:25 +03:00
parent 9faefe85e1
commit 6db7518189
6 changed files with 64 additions and 29 deletions

View File

@@ -1 +1,14 @@
module runtime
$if linux {
#include <sys/sysinfo.h>
fn C.get_nprocs() int
}
pub fn nr_cpus() int {
$if linux {
return C.get_nprocs()
}
return 0
}

View File

@@ -1,5 +1,2 @@
module runtime
pub fn nr_cpus() int {
return 0
}

View File

@@ -2,8 +2,8 @@ import runtime
fn test_nr_cpus() {
$if linux {
nr_cpus := runtime.nr_cpus()
println(nr_cpus)
assert nr_cpus > 0
nr_cpus := runtime.nr_cpus()
println(nr_cpus)
assert nr_cpus > 0
}
}

View File

@@ -1,5 +1,2 @@
module runtime
pub fn nr_cpus() int {
return 0
}