dl
dl_platform.h
浏览该文件的文档.
1
12#pragma once
13
14#define DL_PLATFORM_ERROR 0
15#define DL_PLATFORM_WIN32 1
16#define DL_PLATFORM_LINUX 2
17#define DL_PLATFORM_ANDROID 3
18
19#define DL_PLATFORM DL_PLATFORM_ERROR
20
21#ifdef _WIN32
22#undef DL_PLATFORM
23#define DL_PLATFORM DL_PLATFORM_WIN32
24#endif
25
26#ifdef __linux__
27#undef DL_PLATFORM
28#define DL_PLATFORM DL_PLATFORM_LINUX
29#endif
30
31#ifdef __ANDROID__
32#undef DL_PLATFORM
33#define DL_PLATFORM DL_PLATFORM_ANDROID
34#endif
35
36
38consteval bool is_x64()
39{
40 return sizeof(void*) == 8;
41}
42
44consteval bool is_little_endian()
45{
46#if (DL_PLATFORM == DL_PLATFORM_LINUX || DL_PLATFORM == DL_PLATFORM_ANDROID)
47 return true;
48#else
49 union
50 {
51 int a;
52 char b;
53 }num;
54 num.a = 1;
55 return !num.b;
56#endif
57}
consteval bool is_x64()
是否64位
Definition: dl_platform.h:38
consteval bool is_little_endian()
字节序是否小端
Definition: dl_platform.h:44