aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-01-17 14:00:49 +0000
committergingerBill <bill@gingerbill.org>2018-01-17 14:00:49 +0000
commit9428d86f2b5cb1eea5e4f6e50d3ba72a5dc1769b (patch)
treecbbfb1f3c915f1f5633ec2841710ee4342fae892 /examples
parentddebf0daf2d73faaecbfbc77892d9bdb51adcee2 (diff)
Specific sized booleans: b8, b16, b32, b64
Diffstat (limited to 'examples')
-rw-r--r--examples/demo.odin19
1 files changed, 18 insertions, 1 deletions
diff --git a/examples/demo.odin b/examples/demo.odin
index fce879c1f..3a915e354 100644
--- a/examples/demo.odin
+++ b/examples/demo.odin
@@ -75,6 +75,23 @@ general_stuff :: proc() {
for in 0..2 {} // 0, 1
for in 0...2 {} // 0, 1, 2
}
+
+ { // Multiple sized booleans
+
+ x0: bool; // default
+ x1: b8 = true;
+ x2: b16 = false;
+ x3: b32 = true;
+ x4: b64 = false;
+
+ fmt.printf("x1: %T = %v;\n", x1, x1);
+ fmt.printf("x2: %T = %v;\n", x2, x2);
+ fmt.printf("x3: %T = %v;\n", x3, x3);
+ fmt.printf("x4: %T = %v;\n", x4, x4);
+
+ // Having specific sized booleans is very useful when dealing with foreign code
+ // and to enforce specific alignment for a boolean, especially within a struct
+ }
}
default_struct_values :: proc() {
@@ -632,8 +649,8 @@ using_in :: proc() {
}
main :: proc() {
+ general_stuff();
when false {
- general_stuff();
default_struct_values();
union_type();
parametric_polymorphism();