PRB: Errno Set to -1 After Call to Run-Time Library FunctionLast reviewed: August 8, 1997Article ID: Q138293 |
The information in this article applies to:
SYMPTOMSIn a program built using Visual C++, the global variable errno is set to -1 after calling a C/C++ run-time function.
CAUSEThis occurs because the run-time library made an MS-DOS system call that failed, and the MS-DOS error code could not be mapped to one of the predefined errno values in Errno.h.
RESOLUTIONTo determine what the real error is, check the value of the global variable _doserrno, and call the _dosexterr function to get extended error information from MS-DOS. For more information on MS-DOS error codes and extended error information, please consult the MS-DOS books listed in the "References" section of this article.
MORE INFORMATIONUsually, errno is set to one of the predefined values in Errno.h when an error occurs. For example, if your program calls the _open function to open a file, and it fails and sets errno to the constant EMFILE (defined as 24), it means the program is out of file handles and cannot open any more files. There is no constant for -1 in Errno.h; it is an undocumented value for errno.
REFERENCESVisual C++ Run-Time Library Reference. MS-DOS Programmer's Reference. Advanced MS-DOS Programming. Keywords : CRTIss kb16bitonly Version : 1.0 1.5 1.51 1.52 Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |