This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// creates a variable called "__defer + line number" this variable is destructed at the end of the scope. | |
// on destruction it calls a lambda function that was generated by the macro. | |
// example: | |
// This program outputs "x: 1" | |
/* | |
{ | |
int x = 0; | |
defer(printf("x: %d\n", x)); | |
x++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
intern u64 | |
hash_str(const char* str) { | |
u64 hash = 14695981039346656037ULL; // FNV offset basis | |
i32 c; | |
while ((c = *str++)) { | |
hash ^= (u64)c; | |
hash *= 1099511628211ULL; // FNV prime | |
} | |
return hash; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Types | |
#define TEMPLATE_Vec2t(t) \ | |
typedef union Vec2##t {\ | |
struct {t x, y;};\ | |
t e[2];\ | |
} Vec2##t; | |
#define TEMPLATE_Vec3t(t) \ | |
typedef union Vec3##t {\ | |
struct {t x, y, z;};\ |