2023-09-09 17:14:40 -07:00
|
|
|
#pragma once
|
|
|
|
|
2023-09-08 18:08:57 -07:00
|
|
|
// Keywords
|
|
|
|
|
|
|
|
#define global static // Global variables
|
|
|
|
#define internal static // Internal linkage
|
|
|
|
#define local_persist static // Local Persisting variables
|
2023-09-08 21:01:53 -07:00
|
|
|
|
|
|
|
#define api_c extern "C"
|
2023-09-09 00:03:03 -07:00
|
|
|
|
|
|
|
// Casting
|
|
|
|
|
2023-09-30 07:05:37 -07:00
|
|
|
#define ccast( type, value ) ( const_cast< type >( (value) ) )
|
|
|
|
#define pcast( type, value ) ( * reinterpret_cast< type* >( & ( value ) ) )
|
|
|
|
#define rcast( type, value ) reinterpret_cast< type >( value )
|
|
|
|
#define scast( type, value ) static_cast< type >( value )
|
2023-09-09 20:58:28 -07:00
|
|
|
|
2023-10-11 14:52:13 -07:00
|
|
|
#define do_once() for ( local_persist b32 once = true; once; once = false )
|
2023-09-09 20:58:28 -07:00
|
|
|
|
|
|
|
#define do_once_start \
|
|
|
|
do \
|
|
|
|
{ \
|
2023-09-18 17:16:40 -07:00
|
|
|
local_persist \
|
2023-09-30 07:05:37 -07:00
|
|
|
bool done = false; \
|
|
|
|
if ( done ) \
|
2023-09-09 20:58:28 -07:00
|
|
|
break; \
|
2023-09-30 07:05:37 -07:00
|
|
|
done = true;
|
2023-09-09 20:58:28 -07:00
|
|
|
|
|
|
|
#define do_once_end \
|
|
|
|
} \
|
2023-09-17 18:20:11 -07:00
|
|
|
while(0);
|
|
|
|
|
|
|
|
|
|
|
|
#define array_count( array ) ( sizeof( array ) / sizeof( ( array )[0] ) )
|
2023-09-18 17:16:40 -07:00
|
|
|
|
|
|
|
// TODO(Ed) : Move to memory header eventually
|
|
|
|
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
|
|
|
|
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
|
|
|
|
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
|
|
|
|
#define terabytes( x ) ( gigabytes( x ) * ( s64 )( 1024 ) )
|
|
|
|
|
|
|
|
// TODO(Ed) : Move to debug header eventually
|
|
|
|
|
|
|
|
#if Build_Development
|
|
|
|
# define assert( expression ) \
|
2023-09-21 23:16:40 -07:00
|
|
|
if ( !( expression ) ) \
|
|
|
|
{ \
|
|
|
|
__debugbreak(); \
|
2023-09-18 17:16:40 -07:00
|
|
|
}
|
|
|
|
// platform::assertion_failure( __FILE__, __LINE__, #expression );
|
|
|
|
#else
|
|
|
|
# define assert( expression )
|
|
|
|
#endif
|
|
|
|
|
2023-09-26 14:26:35 -07:00
|
|
|
#ifdef COMPILER_CLANG
|
|
|
|
# define compiler_decorated_func_name __PRETTY_NAME__
|
|
|
|
#elif defined(COMPILER_MSVC)
|
|
|
|
# define compiler_decorated_func_name __FUNCDNAME__
|
|
|
|
#endif
|
|
|
|
|
2023-09-21 23:16:40 -07:00
|
|
|
#if Build_Development
|
2023-10-01 17:17:14 -07:00
|
|
|
# define congrats( message ) platform::impl_congrats( message )
|
|
|
|
# define ensure( condition, message ) platform::impl_ensure( condition, message )
|
|
|
|
# define fatal( message ) platform::impl_fatal( message )
|
2023-09-21 23:16:40 -07:00
|
|
|
#else
|
2023-10-01 17:17:14 -07:00
|
|
|
# define congrats( message )
|
2023-12-29 09:29:22 -08:00
|
|
|
# define ensure( condition, message ) true
|
2023-10-01 17:17:14 -07:00
|
|
|
# define fatal( message )
|
2023-09-21 23:16:40 -07:00
|
|
|
#endif
|