INFO: Compiler Errors with Win32 APIs Ending in "A" or "W" (119331)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 2.1
- Microsoft Visual C++, 32-bit Editions 2.2
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Editions 5.0
- Microsoft Visual C++, 32-bit Editions 6.0
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'
Modification Type: | Major | Last Reviewed: | 12/1/2003 |
---|
Keywords: | kbCompiler kberrmsg kbinfo KB119331 |
---|
|