aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2022-02-15 16:18:07 +0000
committerGitHub <noreply@github.com>2022-02-15 16:18:07 +0000
commitd45ff0694d193fd15b0153ff1696de2b0a8606c3 (patch)
tree594aa38dc02832c92f2b7dc8fd1a155a1c23bc2b /examples
parent0380a288a9e7d5bb775abec00900488659d1c784 (diff)
parentd695a8a52631aafcedeb2472c4d405c51547c651 (diff)
Merge pull request #1438 from odin-lang/odin-global-constants-as-enums
Odin global constants as enums
Diffstat (limited to 'examples')
-rw-r--r--examples/demo/demo.odin18
1 files changed, 9 insertions, 9 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index 8c6ea0fa4..a4b678ae7 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -244,10 +244,10 @@ control_flow :: proc() {
// A switch statement is another way to write a sequence of if-else statements.
// In Odin, the default case is denoted as a case without any expression.
- switch arch := ODIN_ARCH; arch {
- case "386":
+ #partial switch arch := ODIN_ARCH; arch {
+ case .i386:
fmt.println("32-bit")
- case "amd64":
+ case .amd64:
fmt.println("64-bit")
case: // default
fmt.println("Unsupported architecture")
@@ -363,12 +363,12 @@ control_flow :: proc() {
*/
// Example
- when ODIN_ARCH == "386" {
+ when ODIN_ARCH == .i386 {
fmt.println("32 bit")
- } else when ODIN_ARCH == "amd64" {
+ } else when ODIN_ARCH == .amd64 {
fmt.println("64 bit")
} else {
- fmt.println("Unsupported architecture")
+ fmt.println("Unknown architecture")
}
// The when statement is very useful for writing platform specific code.
// This is akin to the #if construct in C’s preprocessor however, in Odin,
@@ -1100,7 +1100,7 @@ prefix_table := [?]string{
}
threading_example :: proc() {
- if ODIN_OS == "darwin" {
+ if ODIN_OS == .Darwin {
// TODO: Fix threads on darwin/macOS
return
}
@@ -1606,13 +1606,13 @@ where_clauses :: proc() {
}
-when ODIN_OS == "windows" {
+when ODIN_OS == .Windows {
foreign import kernel32 "system:kernel32.lib"
}
foreign_system :: proc() {
fmt.println("\n#foreign system")
- when ODIN_OS == "windows" {
+ when ODIN_OS == .Windows {
// It is sometimes necessarily to interface with foreign code,
// such as a C library. In Odin, this is achieved through the
// foreign system. You can “import” a library into the code