在GNU编译器下根据系统预置宏,正确识别是否支持char8_t。(注:仅根据文档实现,待LINUX下测试)

This commit is contained in:
2020-07-11 16:13:19 +08:00
parent 50aa9ce555
commit 9191dcb73c
4 changed files with 16 additions and 15 deletions

View File

@@ -34,11 +34,12 @@ namespace hgl
std::cout<<(char *)str.c_str()<<std::endl;
}
// 对于不支持C++20的编译器还得用宏处理一下
// inline void Log(LogLevel ll,const AnsiString &str)
// {
// std::cout<<str.c_str()<<std::endl;
// }
#ifdef HGL_SUPPORT_CHAR8_T
inline void Log(LogLevel ll,const AnsiString &str)
{
std::cout<<str.c_str()<<std::endl;
}
#endif//HGL_SUPPORT_CHAR8_T
inline void DebugLog(LogLevel ll,const UTF16String &str,const char *filename,int line,const char *funcname)
{

View File

@@ -17,5 +17,12 @@ namespace hgl
using float32 =float;
using float64 =double;
#if defined(__cpp_char8_t)||defined(__cpp_lib_char8_t)
#define HGL_SUPPORT_CHAR8_T
using u8char = char8_t;
#else
using u8char = char;
#endif
}//namespace hgl
#endif//HGL_DATATYPE_GNU_INCLUDE

View File

@@ -72,14 +72,6 @@
#endif//__GNUC__
// 假设 GCC 从 11 开始正式支持 char8_t( 这个我手头没有 11 ,不确定 )
#if __GNUC__ >= 11
using u8char = char8_t;
#else
using u8char = char;
#endif
#define HGL_THREAD_LOCAL_STORAGE __thread //线程本地储存
//--------------------------------------------------------------------------------------------------
#define HGL_LIB_FRONT HGL_LIB_OS "_" HGL_LIB_COMPILER_NAME "_" HGL_LIB_DEBUG_NAME "_"

View File

@@ -21,9 +21,10 @@
#define HGL_THREAD_LOCAL_STORAGE __declspec(thread) //线程本地储存
//--------------------------------------------------------------------------------------------------
#if _MSVC_LANG>=201704L //C++20
using u8char =char8_t;
#define HGL_SUPPORT_CHAR8_T
using u8char =char8_t;
#else
using u8char =char;
using u8char =char;
#endif
#define HGL_FMT_I64 "%I64d"