This is my third attempt to clarify my confusion on this topic. But this time I have different questions.
I have this code
DWORD v1, v2, v3, Build;
GetVersion(&v1, &v2, &v3, &Build);
sprintf(VersionStr, "%d.%d.%d.%d", v1, v2, v3, Build);
which was written using Visual Studio, perhaps 10 years ago. I know that DWORDalways unsignedis the truth ?.
Now, here , one of the answers is quoting some version of the standard (is this standard version applicable to my code?) Which says va_arg:
The standard is not 100% understandable. On the one hand, you get the specification for va_arg , which states (Β§7.15.1.1 / 2):
If the actual next argument is missing or the type is incompatible with the type of the actual next argument (according to the default arguments), the behavior is undefined, except in the following cases:
one type is a signed integer type, another type is the corresponding unsigned integer type , and the value is represented in both types;
one type is a pointer to void, and the other is a pointer to a type symbol.
On the other hand, this answer also speaks of printf
On the other hand, you get the printf specification (Β§7.19.6.1 / 9):
If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined. "
, va_arg, printf. , . , printf, va_arg. . .
, - , undefined ? , , v1, int, undefined ( , )?
, , , , , undefined ?