获取全局误差变量的当前值。
errno_t _get_errno(
int * pValue
);
参数
- [out] pValue
将用整数的指针复制 errno 变量的当前值。
返回值
如果成功,返回零;如果失败,则为错误代码。 如果 pValue 为 NULL,则将调用无效参数处理程序,如参数验证所述。 如果允许执行继续,则该函数设置 errno 为 EINVAL 并返回 EINVAL。
备注
在Errno.h 中定义,可能的 errno 值。 请参见:errno 常量。
示例
// crt_get_errno.c
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <share.h>
#include <errno.h>
int main()
{
errno_t err;
int pfh;
_sopen_s( &pfh, "nonexistent.file", _O_WRONLY, _SH_DENYNO, _S_IWRITE );
_get_errno( &err );
printf( "errno = %d\n", err );
printf( "fyi, ENOENT = %d\n", ENOENT );
}
要求
例程 |
必需的标头 |
可选标头 |
---|---|---|
_get_errno |
<stdlib.h> |
<errno.h> |
有关更多兼容性信息,请参见“简介”中的兼容性。
.NET Framework Equivalent
不适用。 若要调用标准 C 函数,请使用 PInvoke。 有关更多信息,请参见平台调用示例。