IMHO, the compiler should not be blamed for having difficulties interpreting an ambiguous statements. Overloaded subroutines can be the source of big frustration both for the compiler and the programmer. Ask somebody with at least a modest experience in C++
@440bx
Isn't it better that way:
function swprintf_wc({ _out_ } OutWideBuffer : pwidechar;
{ _in_ } InFormatString : pwidechar;
{ _in_ } InWidechars : pwidechar)
: integer; cdecl; external ntdll name 'swprintf';
function swprintf_c({ _out_ } OutWideBuffer : pwidechar;
{ _in_ } InFormatString : pwidechar;
{ _in_ } InAnsiChars : pchar)
: integer; cdecl; external ntdll name 'swprintf';
BTW, It is more related to the functions of varargs than to overloaded ones, IMO they are mainly C language prerogative.
Regards,
The compiler isn't to blame for ambiguous statements. What the compiler can legitimately be blamed for is making choices in situations that are not decidable and _not_ informing the programmer that it made an arbitrary choice that is not guaranteed in any way to be correct. THAT is the problem, the compiler's silence when it made a decision that is simply arbitrary (calling it a "preference" doesn't change the situation.)
As far as the definitions you present, yes, of course it can be done that way but that's foregoes the compiler's abilities to overload definitions. That's just a way of hiding the real problem which is, the compiler's failure to inform the programmer that it made an _arbitrary_ choice that may or may not be correct.
@Woobean
The problem is that the compiler doesn't tell you that a typecast is needed to get it right. The compiler may make the wrong choice and not say anything to the programmer that it may have made an incorrect choice.
Yes, you can typecast to get it right and, it would be much easier for the programmer to know a typecast is required to get it right if the compiler had the courtesy of pointing out that situation to the programmer. That is problem, the lack of "courtesy" from the compiler.