Microsoft KB Archive/119331

= INFO: Compiler Errors with Win32 APIs Ending in "A" or "W" =

Article ID: 119331

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 2.1
 * Microsoft Visual C++ 2.2
 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 4.1 Subscription
 * Microsoft Visual C++ 5.0 Standard Edition
 * Microsoft Visual C++ 6.0 Service Pack 5

-



This article was previously published under Q119331



SUMMARY
When the names of Win32 APIs appear in compiler error messages, they may have either an "A" or a "W" appended to the API name. For example, the API CreateProcess can appear as "CreateProcessA" in an error message such as the following:

error C2664: 'CreateProcessA' : cannot convert parameter 9

The reason for this is that many Win32 APIs have both a ANSI ("A") and a Unicode ("W") version. The Windows NT header files use macros such as the following to select the appropriate API:   #ifdef UNICODE #define CreateProcess CreateProcessW #else #define CreateProcess CreateProcessA #endif // !UNICODE



MORE INFORMATION
The Windows NT header files also contain more complicated macros, which use hidden arguments: #define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y,\   nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y,\   nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y,\   nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y,\   nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) #ifdef UNICODE #define CreateWindow CreateWindowW #else #define CreateWindow CreateWindowA #endif // !UNICODE In this case, an error message may refer to argument 8 on a line of your code, but the argument is really argument 7 in your source code.

Other error messages that may have unexpected diagnostic information because of macro expansion include the following:
 * C1056: compiler limit : out of macro expansion space
 * C2014: preprocessor command must start as first nonwhite space
 * C2055: expected formal parameter list, not a type list
 * C2095: 'function' : actual parameter has type void : parameter 'number'
 * C2172: 'function' : actual parameter is not a pointer : parameter 'number'
 * C2173: 'function' : actual parameter is not a pointer : parameter 'number1', parameter list 'number2'
 * C2174: 'function' : actual parameter has type 'void' : parameter 'number1', parameter list 'number2'
 * C2660: 'function' : function does not take 'number' parameters
 * C2664: 'function' : cannot convert parameter 'number' from 'type1' to 'type2'
 * C4022: 'function' : pointer mismatch for actual parameter 'number'
 * C4024: 'function' : different types for formal and actual parameter 'number'

Additional query words: 8.00 9.00 9.10 10.00 10.10

Keywords: kberrmsg kbinfo kbcompiler KB119331

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.