I'm trying to use Microsoft's cpprestsdk. And I was getting an error, and so I wanted to check the error code. But I'm not able to figure out the format specifier of error_code
, and I'm getting this warning :
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());
How should I print the error code? Although %d
works but I wanted to know the actual specifier so that I won't get any warnings.
PS: I saw some of them here : https://msdn.microsoft.com/en-us/library/75w45ekt(v=vs.120).aspx , but I don't think any of them are any help to me.
std::error_code
is a class and can not be passed as printf argument. But you can pass an int
value returned by error_code::value()
.