Added a definition file that contains some typedefs and platform-specific aliasing (debug_break, static assert, and verifies that the C macro NULL is defined)
This commit is contained in:
73
include/basalt_defines.h
Normal file
73
include/basalt_defines.h
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(__clang__) || defined(__gcc__)
|
||||||
|
#define STATIC_ASSERT(x,y) _Static_assert(x,y)
|
||||||
|
#else
|
||||||
|
#define STATIC_ASSERT(x,y) static_assert(x,y)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL ((void*)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define debug_break() __debugbreak();
|
||||||
|
#else
|
||||||
|
#define debug_break() __builtin_trap();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned char u8;
|
||||||
|
typedef unsigned short u16;
|
||||||
|
typedef unsigned int u32;
|
||||||
|
typedef unsigned long long u64;
|
||||||
|
|
||||||
|
typedef signed char i8;
|
||||||
|
typedef signed short i16;
|
||||||
|
typedef signed int i32;
|
||||||
|
typedef signed long long i64;
|
||||||
|
|
||||||
|
typedef float f32;
|
||||||
|
typedef double f64;
|
||||||
|
|
||||||
|
STATIC_ASSERT(sizeof(u8) == 1, "Expected sizeof(u8) == 1");
|
||||||
|
STATIC_ASSERT(sizeof(u16) == 2, "Expected sizeof(u16) == 2");
|
||||||
|
STATIC_ASSERT(sizeof(u32) == 4, "Expected sizeof(u32) == 4");
|
||||||
|
STATIC_ASSERT(sizeof(u64) == 8, "Expected sizeof(u64) == 8");
|
||||||
|
STATIC_ASSERT(sizeof(i8) == 1, "Expected sizeof(i8) == 1");
|
||||||
|
STATIC_ASSERT(sizeof(i16) == 2, "Expected sizeof(i16) == 2");
|
||||||
|
STATIC_ASSERT(sizeof(i32) == 4, "Expected sizeof(i32) == 4");
|
||||||
|
STATIC_ASSERT(sizeof(i64) == 8, "Expected sizeof(i64) == 8");
|
||||||
|
STATIC_ASSERT(sizeof(f32) == 4, "Expected sizeof(f32) == 4");
|
||||||
|
STATIC_ASSERT(sizeof(f64) == 8, "Expected sizeof(f64) == 8");
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined (__WIN32__)
|
||||||
|
#define BPLATFORM_WINDOWS 1
|
||||||
|
#ifndef _WIN64
|
||||||
|
#error "Only 64-bit windows is supported"
|
||||||
|
#endif
|
||||||
|
#elif defined(__linux__) || defined(__gnu_linux__)
|
||||||
|
#define BPLATFORM_LINUX 1
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
#define BPLATFORM_ANDROID 1
|
||||||
|
#endif
|
||||||
|
#elif defined(__unix__)
|
||||||
|
#define BPLATFORM_UNIX 1
|
||||||
|
#elif defined(_POSIX_VERSION)
|
||||||
|
#define BPLATFORM_POSIX 1
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#define BPLATFORM_APPLE 1
|
||||||
|
#include <TargetConditionals.h>
|
||||||
|
#if TARGET_IPHONE_SIMULATOR
|
||||||
|
#define BPLATFORM_IOS 1
|
||||||
|
#define BPLATFORM_IOS_SIMULATOR 1
|
||||||
|
#elif TARGET_OS_IPHONE
|
||||||
|
#define BPLATFORM_IOS 1
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
#define BPLATFORM_MACOS 1
|
||||||
|
#else
|
||||||
|
#error "Unknown Apple Architecture"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#error "Unknown platform
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user