mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
Replace compile_assert with #assert
This commit is contained in:
@@ -328,7 +328,7 @@ miscellany :: proc() {
|
||||
*/
|
||||
|
||||
// assert(false)
|
||||
// compile_assert(false)
|
||||
// #assert(false)
|
||||
// panic("Panic message goes here")
|
||||
}
|
||||
|
||||
|
||||
@@ -171,8 +171,8 @@ new_builtins :: proc() {
|
||||
{
|
||||
// Compile time assert
|
||||
COND :: true;
|
||||
compile_assert(COND);
|
||||
// compile_assert(!COND)
|
||||
#assert(COND);
|
||||
// #assert(!COND)
|
||||
|
||||
// Runtime assert
|
||||
x := true;
|
||||
|
||||
@@ -43,7 +43,7 @@ syntax :: proc() {
|
||||
Thing2 :: struct {x: f32, y: int, z: ^[]int};
|
||||
|
||||
// Slice interals are now just a `ptr+len+cap`
|
||||
slice: []int; compile_assert(size_of(slice) == 3*size_of(int));
|
||||
slice: []int; #assert(size_of(slice) == 3*size_of(int));
|
||||
|
||||
// Helper type - Help the reader understand what it is quicker
|
||||
My_Int :: #type int;
|
||||
@@ -218,7 +218,7 @@ loops :: proc() {
|
||||
name := "你好,世界";
|
||||
fmt.println(name);
|
||||
for r in name {
|
||||
compile_assert(type_of(r) == rune);
|
||||
#assert(type_of(r) == rune);
|
||||
fmt.printf("%r\n", r);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ when true {
|
||||
* ..< and ... removed and replace with .. (half-closed range)
|
||||
|
||||
Changed:
|
||||
* `compile_assert` and `assert` return the value of the condition for semantic reasons
|
||||
* `#assert` and `assert` return the value of the condition for semantic reasons
|
||||
* thread_local -> #thread_local
|
||||
* #include -> #load
|
||||
* Files only get checked if they are actually used
|
||||
@@ -159,8 +159,8 @@ when true {
|
||||
fmt.println(i);
|
||||
}
|
||||
|
||||
compile_assert(size_of([vector 7]bool) >= size_of([7]bool));
|
||||
compile_assert(size_of([vector 7]i32) >= size_of([7]i32));
|
||||
#assert(size_of([vector 7]bool) >= size_of([7]bool));
|
||||
#assert(size_of([vector 7]i32) >= size_of([7]i32));
|
||||
// align_of([vector 7]i32) != align_of([7]i32) // this may be the case
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ memory_copy :: proc(dst, src: rawptr, n: int) #inline {
|
||||
}
|
||||
|
||||
v128b :: type {4}u32
|
||||
compile_assert(align_of(v128b) == 16)
|
||||
#assert(align_of(v128b) == 16)
|
||||
|
||||
d, s: ^byte = dst, src
|
||||
|
||||
|
||||
Reference in New Issue
Block a user