[英]Cannot open source file err.h in visual studio?
When I run my program on a mac it works just fine, but when I do it using Visual Studio I get this error:当我在 mac 上运行我的程序时,它工作得很好,但是当我使用 Visual Studio 执行它时,我收到此错误:
Cannot open source file err.h
无法打开源文件 err.h
Is there another way to handle errors in Visual studio or am I not calling correctly?是否有另一种方法来处理 Visual Studio 中的错误,或者我没有正确调用?
#include <err.h>
Here's How I'm trying to use err in my code:这是我尝试在代码中使用 err 的方式:
switch (select(1, &readfds, NULL, NULL, &tmo)) {
case -1:
err(1, "select"); // This throw an error
break;
case 0:
printf("You did not enter your password within 5 seconds\n");
return (1);
break;
}
The entire <err.h>
(with err()
, errx()
, warnx
, etc.) is, actually, a BSD-thing, @EdHeal.整个
<err.h>
(带有err()
、 errx()
、 warnx
等)实际上是一个 BSD 的东西,@EdHeal。
Linux adopted it -- smartly. Linux巧妙地采用了它。 Microsoft hasn't -- foolishly.
微软没有——愚蠢地。 Along with the
<sysexits.h>
this is an extremely handy API for proper command-line utilities.与
<sysexits.h>
这是一个非常方便的 API,用于正确的命令行实用程序。
If you only have a single err()
call in the program, you can replace it with something like:如果程序中只有一个
err()
调用,则可以将其替换为:
#include <errno.h>
#include <stdio.h>
#include <string.h>
...
fprintf(stderr, "%s: select: %s\n", argv[0], strerror(errno));
exit(1)`.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.