Assignment of Void Pointer Does Not Give Warning Message (41374)
The information in this article applies to:
- Microsoft C for MS-DOS 6.0
- Microsoft C for MS-DOS 6.0a
- Microsoft C for MS-DOS 6.0ax
- Microsoft C for OS/2 6.0
- Microsoft C for OS/2 6.0a
- Microsoft C/C++ for MS-DOS 7.0
- Microsoft Visual C++ 1.0
- Microsoft Visual C++ 1.5
- Microsoft Visual C++ 1.51
- Microsoft Visual C++, 32-bit Professional Edition 2.0
- Microsoft Visual C++, 32-bit Professional Edition 2.1
This article was previously published under Q41374 SUMMARY
The Sample Code below shows an inconsistency with the way that the
Microsoft compilers listed above deal with pointer checking. The ANSI
standard is unclear about whether an assignment to a void pointer should be
checked to see if it is being assigned a nonpointer variable. The code
below shows that character pointers are checked while void pointers are
not; the code will generate the following warnings:
16-bit compilers
The compiler generates the following warning for the void pointer in the
sample code as well as the character pointer:
C4047: '=' different levels of indirection
32-bit compilers
The compiler generates the following warming with the sample code:
C4047: "=": 'void *' differs in levels of indirection from 'int'
7.0 and later
Compiler versions 7.0 and later generate the following error in both cases
if the program is compiled as a C++ program (.cpp extension).
error C2446: '=' : no conversion from 'int ' to 'void *'
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | KB41374 |
---|
|