Microsoft KB Archive/60253

= Microsoft Knowledge Base =

Data Type Mismatch in Argument Yields C4061 or C4761
Last reviewed: July 22, 1997

Article ID: Q60253

6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00 1.50 | 1.00 2.00 4.00

MS-DOS                | OS/2       | WINDOWS   | WINDOWS NT kbtool kbcode

The information in this article applies to:

The Microsoft C/C++ Compiler (CL.EXE), included with:

- Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax - Microsoft C for OS/2, versions 6.0 and 6.0a - Microsoft C/C++ for MS-DOS, versions 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 - Microsoft Visual C++ 32-bit Edition, versions 1.0, 2.0, and 4.0

SUMMARY
Microsoft C versions earlier than version 6.0 generates the C4061 warning only if the actual and formal function arguments include both long and int data types. Microsoft C version 6.0 and later also generate this message if the actual and formal function arguments include both int and char data types. While C4061 is is not a fatal error, it may provide the only indication of a potential problem.

The fast compiler of Microsoft C/C++ version 7.0, 8.0, and 8.0c for MS-DOS (invoked with the /f compiler option switch) generate the following warning:

warning C4761: integral size mismatch in argument; conversion supplied This also holds true for the Microsoft C/C++ 32-bit compiler, versions 8.0, 9.0, and 10.0.

MORE INFORMATION
The compiler generates the C4761 warning (at warning level 1) for the code example below. The fast compiler provided with C version 6.0 (invoked with the /qc compiler option switch) and the Visual C++ version 1.0 optimizing compiler (invoked with the /f- compiler option switch) do not generate the C4761 warning compiling the code example at any warning level.

Sample Code

 * 1) include 

void myfunc(char); /* At prototype level argument type is CHAR */ void main(void);

void main (void) {

int x = 0; myfunc(x);      /*  Now passing an INTEGER to a CHAR  */ }

void myfunc(char c) /* Argument correctly declared as CHAR */ {}