i8 print test + $if mac => $if macos

pull/2967/head
Alexander Medvednikov 2019-12-03 16:09:37 +03:00
parent b907cf2179
commit ff80e3a5fa
4 changed files with 17 additions and 2 deletions

View File

@ -75,6 +75,16 @@ fn test_and() {
assert c[4] & 1 != 0
}
fn test_i8_print() {
b := i8(0)
println(b)
c := i16(7)
println(c)
d := u16(6)
println(d)
assert true
}
/*
fn test_cmp() {
assert 1 2

View File

@ -289,6 +289,7 @@ fn os_name_to_ifdef(name string) string {
match name {
'windows' { return '_WIN32' }
'mac' { return '__APPLE__' }
'macos' { return '__APPLE__' }
'linux' { return '__linux__' }
'freebsd' { return '__FreeBSD__' }
'openbsd'{ return '__OpenBSD__' }

View File

@ -23,6 +23,9 @@ fn (p mut Parser) comp_time() {
p.fspace()
if name in supported_platforms {
ifdef_name := os_name_to_ifdef(name)
if name == 'mac' {
p.warn('use `macos` instead of `mac`')
}
if not {
p.genln('#ifndef $ifdef_name')
}

View File

@ -25,8 +25,8 @@ enum BuildMode {
}
const (
supported_platforms = ['windows', 'mac', 'linux', 'freebsd', 'openbsd',
'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku']
supported_platforms = ['windows', 'mac', 'macos', 'linux', 'freebsd',
'openbsd', 'netbsd', 'dragonfly', 'android', 'js', 'solaris', 'haiku']
)
enum OS {
@ -1141,6 +1141,7 @@ pub fn os_from_string(os string) OS {
'linux' { return .linux}
'windows' { return .windows}
'mac' { return .mac}
'macos' { return .mac}
'freebsd' { return .freebsd}
'openbsd' { return .openbsd}
'netbsd' { return .netbsd}