_get_errno
获取 errno 全局变量的当前值。
errno_t _get_errno(
int * pValue
);
参数
- [out]pValue
要填充的整数的指针 errno 变量的当前值。
返回值
返回零,如果成功;在失败的错误代码。 如果 pValue 是 NULL,无效参数调用处理程序 参数验证如中所述。 如果执行允许继续,此功能设置 errno 到 EINVAL 并返回 EINVAL。
备注
errno 的可能值在 Errno.h 定义。 请参见: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 等效
不适用。 若要调用标准 C 函数,请使用 PInvoke。 有关更多信息,请参见 平台调用示例。