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 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() { fn test_cmp() {
assert 1 2 assert 1 2

View File

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

View File

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

View File

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