gpt4 book ai didi

c++ - error_code 的格式说明符是什么?

转载 作者:行者123 更新时间:2023-11-27 22:40:27 27 4
gpt4 key购买 nike

我正在尝试使用 Microsoft 的 cpprestsdk。我遇到了一个错误,所以我想检查错误代码。但是我无法弄清楚 error_code 的格式说明符,我收到了这个警告:

warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘const std::error_code’ [-Wformat=] printf("HTTP Exception :: %s\nCode :: %d\n", e.what(), e.error_code());

我应该如何打印错误代码?虽然 %d 有效,但我想知道实际的说明符,这样我就不会收到任何警告。

PS:我在这里看到了其中的一些:https://msdn.microsoft.com/en-us/library/75w45ekt(v=vs.120).aspx ,但我认为它们对我没有任何帮助。

最佳答案

std::error_code 是一个类,不能作为 printf 参数传递。但是您可以传递 error_code::value() 返回的 int 值。

关于c++ - error_code 的格式说明符是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49451421/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com