Everything is working as intended, and I get the values I need from va_arg(va_list, type), but I get this warning everywhere I call va_arg:
Warning C6285 (<non-zero constant> || <non-zero constant>) is always a non-zero constant. Did you intend to use the bitwise-and operator?
Example code:
void Logger::log(LogLevel level, const char* location, uint32_t line, const char* format, ...)
{
va_list arg_ptr;
va_start(arg_ptr, format);
while (*format) {
// ...
if (*format == 'd') { //
int i = va_arg(arg_ptr, int); // <-- Warning is reported here
// ...
}
// ...
++format;
}
// ...
va_end(arg_ptr);
}
Why do I get this warning and how can I get rid of it?
I'm using Visual Studio Community 2019 with Visual C++ 2019
C6###
error codes are IntelliSense codes. These are based on heuristics and are meant to point the attention to potential errors, but can also result in false-positives, which seems to be the case here; it's probably triggering on the va_arg
implementation in the CRT:
#define __crt_va_arg(ap, t) \
((sizeof(t) > sizeof(__int64) || (sizeof(t) & (sizeof(t) - 1)) != 0) \ // <== Here
? **(t**)((ap += sizeof(__int64)) - sizeof(__int64)) \
: *(t* )((ap += sizeof(__int64)) - sizeof(__int64)))
I would simply ignore it...
If it bothers you, report it to the vendor: Help → Send Feedback → Report a Problem...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.