HandmadeHero/project/platform/grime.hpp

78 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
2023-09-08 18:08:57 -07:00
#pragma region Platform Detection
/* Platform architecture */
#if defined( _WIN64 ) || defined( __x86_64__ ) || defined( _M_X64 ) || defined( __64BIT__ ) || defined( __powerpc64__ ) || defined( __ppc64__ ) || defined( __aarch64__ )
2023-09-13 21:43:35 -07:00
# ifndef ARCH_64_BIT
# define ARCH_64_BIT 1
2023-09-08 18:08:57 -07:00
# endif
#else
2023-09-13 21:43:35 -07:00
# error A 32-bit architecture is not supported
2023-09-08 18:08:57 -07:00
#endif
/* Platform OS */
#if defined( _WIN32 ) || defined( _WIN64 )
2023-10-20 23:09:44 -07:00
# ifndef System_Windows
# define System_Windows 1
2023-09-08 18:08:57 -07:00
# endif
#elif defined( __APPLE__ ) && defined( __MACH__ )
2023-10-20 23:09:44 -07:00
# ifndef System_OSX
# define System_OSX 1
2023-09-08 18:08:57 -07:00
# endif
2023-10-20 23:09:44 -07:00
# ifndef System_MacOS
# define System_MacOS 1
2023-09-08 18:08:57 -07:00
# endif
#elif defined( __unix__ )
2023-10-20 23:09:44 -07:00
# ifndef System_Unix
# define System_Unix 1
2023-09-08 18:08:57 -07:00
# endif
# if defined( ANDROID ) || defined( __ANDROID__ )
2023-10-20 23:09:44 -07:00
# ifndef System_Android
# define System_Android 1
2023-09-08 18:08:57 -07:00
# endif
2023-09-13 21:43:35 -07:00
# ifndef SYSTEM_LINUX
2023-10-20 23:09:44 -07:00
# define System_Linux 1
2023-09-08 18:08:57 -07:00
# endif
# elif defined( __linux__ )
2023-10-20 23:09:44 -07:00
# ifndef System_Linux
# define System_linux 1
2023-09-08 18:08:57 -07:00
# endif
# else
# error This UNIX operating system is not supported
# endif
#else
# error This operating system is not supported
#endif
/* Platform compiler */
#if defined( _MSC_VER )
2023-10-20 23:09:44 -07:00
# define Compiler_MSVC 1
2023-09-08 18:08:57 -07:00
#elif defined( __clang__ )
2023-10-20 23:09:44 -07:00
# define Compiler_Clang 1
2023-09-13 21:43:35 -07:00
#else
2023-10-20 23:09:44 -07:00
# error "Unknown compiler"
2023-09-08 18:08:57 -07:00
#endif
#if defined( __has_attribute )
2023-09-13 21:43:35 -07:00
# define HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
2023-09-08 18:08:57 -07:00
#else
2023-09-13 21:43:35 -07:00
# define HAS_ATTRIBUTE( attribute ) ( 0 )
2023-09-08 18:08:57 -07:00
#endif
#pragma endregion Platform Detection
#pragma region Mandatory Includes
# include <stdarg.h>
# include <stddef.h>
2023-10-20 23:09:44 -07:00
# if defined( System_Windows )
2023-09-08 18:08:57 -07:00
# include <intrin.h>
# endif
#pragma endregion Mandatory Includes