PRB: C4058 Generated with /ASu, /ASw, /AMu, and /AMwLast reviewed: July 17, 1997Article ID: Q37632 |
6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00 1.50
MS-DOS | OS/2 | WINDOWSkbtool kbprb 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, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
SYMPTOMSAn attempt to pass the address of a local variable to a function that expects a pointer fails when the compiler options include /ASu, /ASw, /AMu, or /AMw. C versions 6.x generate the following message:
C4058: address of automatic (local) variable taken, DS != SSC/C++ version 7.0 generates the following message:
C4762: near/far mismatch in argument; conversion suppliedIn C/C++ versions 8.0 and 8.0c, the message depends on the option selected. If the command line includes /ASw or /AMw, the compiler produces the following messages:
C4758: address of automatic (local) variable taken, DS != SS C4762: near/far mismatch in argument : conversion suppliedIf the command line includes /ASu or /AMu, the compiler produces the following message:
C4762: near/far mismatch in argument : conversion supplied CAUSEThe segment setup codes "u" and "w" inform the compiler that the stack segment (SS) and the data segment (DS) are not necessarily identical. In the small and medium memory models, data pointers are assumed to be near (in DS) and local variables are stored on the stack (in SS). The warnings occur because DS and SS may not be equal.
RESOLUTIONTo eliminate the warning, perform one of the following:
MORE INFORMATIONThe following sample code illustrates the situation:
Sample Code
/* * Compile options needed: /AMw */ void inc(int *); void main(void){ int p = 666; inc(&p); /* address of stack variable */ } void inc(int *p){ (*p)++;}
|
Additional reference words: 1.00 1.50 6.00 6.00a 6.00ax 7.00 8.00 8.00c
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |