实现基本 TypeTraits

This commit is contained in:
2021-10-03 22:40:10 +08:00
parent dce84d24a4
commit 7361a673e4
3 changed files with 181 additions and 10 deletions

View File

@ -4,10 +4,12 @@
#include <cstdint>
#include <cstdlib>
#include <cstddef>
NS_REDCRAFT_BEGIN
// Function type macros.
#if PLATFORM_WINDOWS
#define VARARGS __cdecl
@ -43,6 +45,7 @@ NS_REDCRAFT_BEGIN
#endif
// Alignment.
#if defined(__clang__)
#define GCC_PACK(n) __attribute__((packed,aligned(n)))
@ -60,7 +63,8 @@ NS_REDCRAFT_BEGIN
#endif
// DLL export and import definitions
// DLL export and import definitions.
#if PLATFORM_WINDOWS
#define DLLEXPORT __declspec(dllexport)
@ -79,32 +83,41 @@ NS_REDCRAFT_BEGIN
#endif
// Unsigned base types.
typedef std::uint8_t uint8;
typedef std::uint16_t uint16;
typedef std::uint32_t uint32;
typedef std::uint64_t uint64;
// Signed base types.
typedef std::int8_t int8;
typedef std::int16_t int16;
typedef std::int32_t int32;
typedef std::int64_t int64;
// Character types.
typedef char ANSICHAR;
typedef wchar_t WIDECHAR;
typedef WIDECHAR TCHAR;
// Pointer types
// Pointer types.
typedef std::uintptr_t uintptr_t;
typedef std::intptr_t intptr_t;
typedef std::size_t size_t;
typedef intptr_t ssize_t;
// Null types
// Null types.
typedef decltype(NULL) null_t;
typedef std::nullptr_t nullptr_t;
// Alignment.
typedef std::max_align_t max_align_t;
#if PLATFORM_LINUX
#define PLATFORM_TCHAR_IS_CHAR16 1
#else
@ -112,6 +125,7 @@ typedef std::nullptr_t nullptr_t;
#endif
// Define the TEXT macro.
#if PLATFORM_TCHAR_IS_CHAR16
#define TEXT_PASTE(x) u ## x
#else