pelicanmapping / rocky

3D Geospatial SDK (C++17 / Vulkan / VSG)
MIT License
91 stars 15 forks source link

compile error with c++20 #23

Closed x1244 closed 7 months ago

x1244 commented 7 months ago

When compile rdemo with cxxflage c++20,got the error

rocky/Utils.h(422): error C2665: “std::to_string”: 没有重载函数可以转换所有参数类型

the code is

Log()->info(std::to_string(std::this_thread::get_id()) + " : " + _me + " = " + std::to_string(d) + "us");

the type of std::thread_id can not convert to int float or double. when conert to string, should use

std::hash{}(std::this_thread::get_id())

or

std::stringstream ss; ss << std::this_thread::get_id(); uint64_t id = std::stoull(ss.str());

And there another error of thread

rocky/Threading.h(465): error C2947: 应由“>”终止 模板参数列表,却找到“<”

compile output

checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.38.33130
[ 25%]: compiling.release rdemo.cpp
error: rdemo.cpp
c:\dev\vs2022\include\rocky/Utils.h(422): error C2665: “std::to_string”: 没有重载函数可以转换所有参数类型
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(538): note: 可能是“std::string std::to_string(long double)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(long double)”: 无法将参数 1 从“std::thread::id”转换为“long double”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(534): note: 或    “std::string std::to_string(float)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(float)”: 无法将参数 1 从“std::thread::id”转换为“float”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(527): note: 或    “std::string std::to_string(double)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(double)”: 无法将参数 1 从“std::thread::id”转换为“double”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(523): note: 或    “std::string std::to_string(unsigned __int64)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(unsigned __int64)”: 无法将参数 1 从“std::thread::id”转换为“unsigned __int64”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(519): note: 或    “std::string std::to_string(__int64)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(__int64)”: 无法将参数 1 从“std::thread::id”转换为“__int64”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(515): note: 或    “std::string std::to_string(unsigned long)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(unsigned long)”: 无法将参数 1 从“std::thread::id”转换为“unsigned long”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(511): note: 或    “std::string std::to_string(long)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(long)”: 无法将参数 1 从“std::thread::id”转换为“long”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(507): note: 或    “std::string std::to_string(unsigned int)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(unsigned int)”: 无法将参数 1 从“std::thread::id”转换为“unsigned int”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\string(503): note: 或    “std::string std::to_string(int)”
c:\dev\vs2022\include\rocky/Utils.h(422): note: “std::string std::to_string(int)”: 无法将参数 1 从“std::thread::id”转换为“int”
c:\dev\vs2022\include\rocky/Utils.h(422): note: 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
c:\dev\vs2022\include\rocky/Utils.h(422): note: 尝试匹配参数列表“(std::thread::id)”时
c:\dev\vs2022\include\rocky/Utils.h(422): note: 模板实例化上下文(最早的实例化上下文)为
c:\dev\vs2022\include\rocky/Utils.h(425): note: 查看对正在编译的 类 模板 实例化“rocky::util::scoped_chrono<T>”的引用
c:\dev\vs2022\include\rocky/Threading.h(465): error C2947: 应由“>”终止 模板参数列表,却找到“<”
c:\dev\vs2022\include\rocky/Threading.h(465): error C2988: 不可识别的模板声明/定义
c:\dev\vs2022\include\rocky/Threading.h(465): error C2143: 语法错误: 缺少“)”(在“&”的前面)
c:\dev\vs2022\include\rocky/Threading.h(465): error C2143: 语法错误: 缺少“;”(在“&”的前面)
c:\dev\vs2022\include\rocky/Threading.h(465): error C2238: 意外的标记位于“;”之前
c:\dev\vs2022\include\rocky/Threading.h(465): error C2059: 语法错误:“&”
c:\dev\vs2022\include\rocky/Threading.h(465): error C2059: 语法错误:“)”
c:\dev\vs2022\include\rocky/Threading.h(465): error C2039: "type": 不是 "`global namespace'" 的成员
c:\dev\vs2022\include\rocky/Threading.h(467): error C2334: “{”的前面有意外标记;跳过明显的函数体
c:\dev\vs2022\include\rocky/Threading.h(475): error C2947: 应由“>”终止 模板参数列表,却找到“<”
c:\dev\vs2022\include\rocky/Threading.h(475): error C2988: 不可识别的模板声明/定义
c:\dev\vs2022\include\rocky/Threading.h(475): error C2143: 语法错误: 缺少“)”(在“&”的前面)
c:\dev\vs2022\include\rocky/Threading.h(475): error C2143: 语法错误: 缺少“;”(在“&”的前面)
c:\dev\vs2022\include\rocky/Threading.h(475): error C2238: 意外的标记位于“;”之前
c:\dev\vs2022\include\rocky/Threading.h(475): error C2059: 语法错误:“&”
c:\dev\vs2022\include\rocky/Threading.h(475): error C2059: 语法错误:“)”
c:\dev\vs2022\include\rocky/Threading.h(475): error C2039: "type": 不是 "`global namespace'" 的成员
c:\dev\vs2022\include\rocky/Threading.h(477): error C2334: “{”的前面有意外标记;跳过明显的函数体
c:\dev\vs2022\include\rocky/Threading.h(488): error C2947: 应由“>”终止 模板参数列表,却找到“<”
c:\dev\vs2022\include\rocky/Threading.h(488): error C2988: 不可识别的模板声明/定义
c:\dev\vs2022\include\rocky/Threading.h(488): error C2143: 语法错误: 缺少“)”(在“&”的前面)
c:\dev\vs2022\include\rocky/Threading.h(488): error C2143: 语法错误: 缺少“;”(在“&”的前面)
c:\dev\vs2022\include\rocky/Threading.h(488): error C2238: 意外的标记位于“;”之前
c:\dev\vs2022\include\rocky/Threading.h(488): error C2059: 语法错误:“&”
c:\dev\vs2022\include\rocky/Threading.h(488): error C2059: 语法错误:“)”
c:\dev\vs2022\include\rocky/Threading.h(488): error C2039: "type": 不是 "`global namespace'" 的成员
c:\dev\vs2022\include\rocky/Threading.h(490): error C2334: “{”的前面有意外标记;跳过明显的函数体
c:\dev\vs2022\include\rocky/Threading.h(507): error C2947: 应由“>”终止 模板参数列表,却找到“<”
c:\dev\vs2022\include\rocky/Threading.h(507): error C2988: 不可识别的模板声明/定义
c:\dev\vs2022\include\rocky/Threading.h(507): error C2143: 语法错误: 缺少“)”(在“&”的前面)
c:\dev\vs2022\include\rocky/Threading.h(507): error C2143: 语法错误: 缺少“;”(在“&”的前面)
c:\dev\vs2022\include\rocky/Threading.h(507): error C2238: 意外的标记位于“;”之前
c:\dev\vs2022\include\rocky/Threading.h(507): error C2059: 语法错误:“&”
c:\dev\vs2022\include\rocky/Threading.h(507): error C2059: 语法错误:“)”
c:\dev\vs2022\include\rocky/Threading.h(507): error C2039: "type": 不是 "`global namespace'" 的成员
c:\dev\vs2022\include\rocky/Threading.h(509): error C2334: “{”的前面有意外标记;跳过明显的函数体
c:\dev\vs2022\include\rocky/Threading.h(567): error C2989: “rocky::util::job_scheduler”: 类 模板 已经声明为非类 模板
c:\dev\vs2022\include\rocky/Threading.h(386): note: 参见“rocky::util::job_scheduler”的声明
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\typeindex(77): error C3203: "type_index": 未指定的 类 模板 不能用作 模板 参数 "_Kty" 的 模板 参数,应为真实类型
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\typeindex(77): error C2908: 显式专用化;已实例化“std::hash<int>”
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\typeindex(77): error C2766: 显式专用化;已定义“std::hash<int>”
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\system_error(455): note: 参见“hash<int>”的前一个定义
c:\dev\vs2022\include\vsg/utils/SharedObjects.h(79): error C3203: "type_index": 未指定的 类 模板 不能用作 模板 参数 "_Kty" 的 模板 参 数,应为真实类型
c:\dev\vs2022\include\vsg/utils/SharedObjects.h(80): error C3203: "type_index": 未指定的 类 模板 不能用作 模板 参数 "_Kty" 的 模板 参 数,应为真实类型
c:\dev\vs2022\include\rocky/vsg/engine/Runtime.h(107): error C2440: “默认参数”: 无法从“initializer list”转换为“const rocky::util::job &”
c:\dev\vs2022\include\rocky/vsg/engine/Runtime.h(107): note: 原因如下: 无法从“initializer list”转换为“const rocky::util::job”
c:\dev\vs2022\include\rocky/vsg/engine/Runtime.h(107): note: 无效的聚合初始化
c:\dev\vs2022\include\rocky/vsg/engine/Utils.h(219): error C2059: 语法错误:“)”
c:\dev\vs2022\include\rocky/vsg/engine/Utils.h(219): note: 模板实例化上下文(最早的实例化上下文)为
c:\dev\vs2022\include\rocky/vsg/engine/Utils.h(256): note: 查看对正在编译的 类 模板 实例化“rocky::util::PromiseOperation<T>”的引用
c:\dev\vs2022\include\rocky/vsg/engine/Utils.h(234): error C2059: 语法错误:“)”
c:\dev\vs2022\include\rocky/vsg/engine/Utils.h(240): error C2059: 语法错误:“)”
D:\laboratory\rocky\rdemo\Demo_Stats.h(70): error C2664: “int sprintf(char *const ,const char *const ,...)”: 无法将参数 2 从“const char8_t [9]”转换为“const char *const ”
D:\laboratory\rocky\rdemo\Demo_Stats.h(70): note: 指向的类型不相关; 转换需要 reinterpret_cast、C 样式强制转换或带圆括号的函数样式强制 转换
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1764): note: 参见“sprintf”的声明
D:\laboratory\rocky\rdemo\Demo_Stats.h(70): note: 尝试匹配参数列表“(char [256], const char8_t [9], unsigned __int64)”时
D:\laboratory\rocky\rdemo\Demo_Stats.h(73): error C2664: “int sprintf(char *const ,const char *const ,...)”: 无法将参数 2 从“const char8_t [9]”转换为“const char *const ”
D:\laboratory\rocky\rdemo\Demo_Stats.h(73): note: 指向的类型不相关; 转换需要 reinterpret_cast、C 样式强制转换或带圆括号的函数样式强制 转换
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1764): note: 参见“sprintf”的声明
D:\laboratory\rocky\rdemo\Demo_Stats.h(73): note: 尝试匹配参数列表“(char [256], const char8_t [9], unsigned __int64)”时
D:\laboratory\rocky\rdemo\Demo_Stats.h(76): error C2664: “int sprintf(char *const ,const char *const ,...)”: 无法将参数 2 从“const char8_t [9]”转换为“const char *const ”
D:\laboratory\rocky\rdemo\Demo_Stats.h(76): note: 指向的类型不相关; 转换需要 reinterpret_cast、C 样式强制转换或带圆括号的函数样式强制 转换
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt\stdio.h(1764): note: 参见“sprintf”的声明
D:\laboratory\rocky\rdemo\Demo_Stats.h(76): note: 尝试匹配参数列表“(char [256], const char8_t [9], unsigned __int64)”时
D:\laboratory\rocky\rdemo\Demo_Stats.h(98): error C2955: “rocky::util::job_metrics”: 使用 类 模板 需要 模板 参数列表
c:\dev\vs2022\include\rocky/Threading.h(519): note: 参见“rocky::util::job_metrics”的声明
D:\laboratory\rocky\rdemo\Demo_Stats.h(98): error C2027: 使用了未定义类型“rocky::util::job_metrics”
c:\dev\vs2022\include\rocky/Threading.h(519): note: 参见“rocky::util::job_metrics”的声明
D:\laboratory\rocky\rdemo\Demo_Stats.h(98): error C3861: “get”: 找不到标识符
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): error C2672: “begin”: 未找到匹配的重载函数
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xutility(1824): note: 可能是“_Ty *std::begin(_Ty (&)[_Size]) noexcept”
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: “_Ty *std::begin(_Ty (&)[_Size]) noexcept”: 无法从“unknown-type”推导出“_Ty (&)[_Size]”的 模板 参数
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xutility(1806): note: 或    “unknown-type std::begin(const _Container &) noexcept(<expr>)”
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: 未能使函数模板“unknown-type std::begin(const _Container &) noexcept(<expr>)”专用化
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: 用下列模板参数:
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: “_Container=unknown-type”
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xutility(1800): note: 或    “unknown-type std::begin(_Container &) noexcept(<expr>)”
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: 未能使函数模板“unknown-type std::begin(_Container &) noexcept(<expr>)”专用化
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: 用下列模板参数:
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: “_Container=unknown-type”
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\initializer_list(54): note: 或    “const _Elem *std::begin(std::initializer_list<_Elem>) noexcept”
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: “const _Elem *std::begin(std::initializer_list<_Elem>) noexcept”: 无法从“unknown-type”推导出“std::initializer_list<_Elem>”的 模板 参数
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): error C2672: “end”: 未找到匹配的重载函数
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xutility(1829): note: 可能是“_Ty *std::end(_Ty (&)[_Size]) noexcept”
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: “_Ty *std::end(_Ty (&)[_Size]) noexcept”: 无法从“unknown-type”推导出“_Ty (&)[_Size]”的 模板 参数
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xutility(1818): note: 或    “unknown-type std::end(const _Container &) noexcept(<expr>)”
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: 未能使函数模板“unknown-type std::end(const _Container &) noexcept(<expr>)”专用化
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: 用下列模板参数:
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: “_Container=unknown-type”
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xutility(1812): note: 或    “unknown-type std::end(_Container &) noexcept(<expr>)”
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: 未能使函数模板“unknown-type std::end(_Container &) noexcept(<expr>)”专用化
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: 用下列模板参数:
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: “_Container=unknown-type”
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\initializer_list(59): note: 或    “const _Elem *std::end(std::initializer_list<_Elem>) noexcept”
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): note: “const _Elem *std::end(std::initializer_list<_Elem>) noexcept”: 无法从“unknown-type”推导出“std::initializer_list<_Elem>”的 模板 参数
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): error C3536: “<begin>$L0”: 初始化之前无法使用
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): error C3536: “<end>$L0”: 初始化之前无法使用
D:\laboratory\rocky\rdemo\Demo_Stats.h(101): error C2100: 非法的间接寻址
D:\laboratory\rocky\rdemo\Demo_Stats.h(105): warning C4473: “sprintf”: 没有为格式字符串传递足够的参数
D:\laboratory\rocky\rdemo\Demo_Stats.h(105): note: 占位符和其参数预计 3 可变参数,但提供的却是 0 参数
D:\laboratory\rocky\rdemo\Demo_Stats.h(105): note: 缺失的可变参数 1 为格式字符串“%d”所需
gwaldron commented 7 months ago

Thank you. I did push a replacement for the this_thread::get_id issue. I think the second issue may be because of std::result_of which was allegedly removed in C++20...? For now, Rocky does require a C++17 compatible compiler.

x1244 commented 7 months ago

Do you have any ideas about supporting C++20.

gwaldron commented 7 months ago

If you want to submit a PR we will take a look. I do not mind supporting C++20 as long as we can still support C++17 as well and the code is not too messy.

x1244 commented 7 months ago

Thinks. I'll keep following, and once I have time, I'll do something c++20 compatible.