Skip to content

Instantly share code, notes, and snippets.

@CynicalApe
Last active July 6, 2019 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CynicalApe/ce6f3796f10144169b95446a096671fc to your computer and use it in GitHub Desktop.
Save CynicalApe/ce6f3796f10144169b95446a096671fc to your computer and use it in GitHub Desktop.
#pragma once
#include <inttypes.h>
#include "types.h"
/* JUST CONVINIENCE DON'T JUDGE ME */
typedef int64_t i64;
typedef int32_t i32;
typedef int16_t i16;
typedef int8_t i8;
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef float f32;
typedef double f64;
typedef int64_t b64;
typedef int32_t b32;
typedef int16_t b16;
typedef int8_t b8;
#define array_item_count(Array) (sizeof(Array) / sizeof((Array)[0]))
#define Kilobytes(Value) (Value * 1024LL)
#define Megabytes(Value) (Kilobytes(Value) * 1024LL)
#define Gigabytes(Value) (Megabytes(Value) * 1024LL)
#define Terabytes(Value) (Gigabytes(Value) * 1024LL)
#define insert_padding(value) u8 padding[value];
#ifdef ENABLE_DEBUGGING
// Assert -> Writes to NULL just to break. Easiest method for asserting prob.
#define assert_fail(Expression) \
if (!(Expression)) \
{ \
*(int*)0 = 0; \
}
#define assert_msg(Expression, msg, ...) \
if (!(Expression)) \
{ \
printf("" msg "\n", ##__VA_ARGS__); \
*(int*)0 = 0; \
}
#define debug_print(f_str, ...) \
fprintf(stderr, "DBG: %s:%d:%s(): " f_str "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__)
#define println(f_str, ...) printf("" f_str "\n", ##__VA_ARGS__);
#else
#define debug_print(Expression)
#define println(Expression)
#define assert_fail(Expression)
#define assert_msg(Expression)
#endif
/*
PREPROCESSOR DEFINITIONS
PERFORMANCE_BUILD:
if defined: Optimizations are enabled
else: no optimization
ENABLE_DEBUGGING:
if defined: Debugging macros such as Assert or Debug Break enabled
else: no debuging macros
INTERNAL_BUILD:
if defined: Build for my specific machine (to have specific pointer addresses etc)
else : build for shipping
*/
#ifdef INTERNAL_BUILD
#define SHIPPING_BUILD 0
#else
#define SHIPPING_BUILD 1
#endif
#ifdef PERFORMANCE_BUILD
#define OPTIMIZATIONS_ENABLED 1
#else
#define OPTIMIZATIONS_ENABLED 0
#endif
#ifdef ENABLE_DEBUGGING
#define DEBUGGING_CODE_ENABLED 1
#define CONTAINER_BOUNDARY_CHECK 1
#else
#define DEBUGGING_CODE_ENABLED 0
#define CONTAINER_BOUNDARY_CHECK 0
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment