error: ‘fileno’ was not declared in this scope
error: ‘fileno’ was not declared in this scope
我是 运行 Cygwin,在 windows 8 上,正在尝试编译我想要 mod 的游戏的源代码。不幸的是,我 运行 在构建涉及 fileno 函数时遇到了一些错误。在谷歌搜索之后,问题似乎与 c++11 支持有关(我不太确定这意味着什么)。人们发现的大多数解决方案都涉及在编译时添加一些选项,如 -std=c++0x 或 -std=c++11,但我尝试将选项添加到 makefile 中的尝试没有成功,我不知道如果那是导致问题的原因。我将包含引发错误的代码片段和一个 link 到 makefile,因为它非常大。如果你能给我任何建议,那就太好了。
抛出错误的代码:
time_t file_modtime(FILE *f)
{
struct stat filestat;
if (fstat(fileno(f), &filestat))
return 0;
return filestat.st_mtime;
}
它托管在 github
编辑:在得到一些建议后,我查看了 makefile 并找到了五个使用了 -std 选项的实例,并没有改变任何东西。我的 Cygwin 配置有问题吗?我在正在构建的游戏的安装指南中安装了我被告知需要的软件包。
将 makefile 中的 -std=c***
更改为 -std=gnu++0x
应该可以解决您的问题。
如果您不知道 c++11
是什么,您很可能不会使用它。
此外,如果您需要 c++11
支持,您也可以这样做:-std=gnu++11
而不是 -std=gnu++0x
对于windows...
fileno()
已弃用:https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-fileno?view=vs-2017
改用_fileno()
:https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fileno?view=vs-2017
我是 运行 Cygwin,在 windows 8 上,正在尝试编译我想要 mod 的游戏的源代码。不幸的是,我 运行 在构建涉及 fileno 函数时遇到了一些错误。在谷歌搜索之后,问题似乎与 c++11 支持有关(我不太确定这意味着什么)。人们发现的大多数解决方案都涉及在编译时添加一些选项,如 -std=c++0x 或 -std=c++11,但我尝试将选项添加到 makefile 中的尝试没有成功,我不知道如果那是导致问题的原因。我将包含引发错误的代码片段和一个 link 到 makefile,因为它非常大。如果你能给我任何建议,那就太好了。
抛出错误的代码:
time_t file_modtime(FILE *f)
{
struct stat filestat;
if (fstat(fileno(f), &filestat))
return 0;
return filestat.st_mtime;
}
它托管在 github
编辑:在得到一些建议后,我查看了 makefile 并找到了五个使用了 -std 选项的实例,并没有改变任何东西。我的 Cygwin 配置有问题吗?我在正在构建的游戏的安装指南中安装了我被告知需要的软件包。
将 makefile 中的 -std=c***
更改为 -std=gnu++0x
应该可以解决您的问题。
如果您不知道 c++11
是什么,您很可能不会使用它。
此外,如果您需要 c++11
支持,您也可以这样做:-std=gnu++11
而不是 -std=gnu++0x
对于windows...
fileno()
已弃用:https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-fileno?view=vs-2017
改用_fileno()
:https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fileno?view=vs-2017