在Cygwin中编译:“EOF”在此范围内未声明,在CentOS中编译良好

时间:2022-04-06 20:18:54

I am running into issues compiling Linux-bound applications in Cygwin.

我在Cygwin中编译linux绑定应用程序时遇到了一些问题。

This error:

这个错误:

error: ‘EOF’ was not declared in this scope

is produced by the following code snippet

是否由以下代码片段生成

if (option == EOF) break;

Compiling this in CentOS directly produces no errors.

在CentOS中编译它直接不会产生错误。

These are the g++ params passed by the make file:

这些是通过make文件传递的g+ params:

-g -O0 -Wall -Wextra -std=gnu++11

GCC version on centOS:

在centOS的GCC版本:

 4.8.1 20130715

GCC version in Cygwin

在Cygwin的GCC版本

 4.8.2

I am wondering if I am just missing some libraries in Cygwin, or if this is just a limitation of Cygwin and can't be resolved.

我想知道我是否只是错过了Cygwin中的一些库,或者这只是Cygwin的局限性,无法解决。

1 个解决方案

#1


4  

EOF is defined in stdio.h / cstdio. What is likely happening is that you aren't including one of those headers, but are including, for example, iostream. Standard library headers are permitted to cause other headers to get included as well, and some implementations' iostream headers do exactly this, but not all. You shouldn't rely on it. If you use EOF, add an explicit include for the appropriate header in your own code. (Even if it isn't your code, which it isn't in this case, the modification required in the source code is the same.)

EOF在stdio中定义。h / cstdio。可能发生的情况是,您不包括其中一个头文件,而是包括,例如,iostream。标准的库头也允许包含其他头,一些实现的iostream头也可以做到这一点,但不是全部。你不应该依赖它。如果您使用EOF,请在您自己的代码中为适当的头添加一个显式的包含。(即使不是您的代码(在本例中不是),源代码所需的修改也是一样的。)

#1


4  

EOF is defined in stdio.h / cstdio. What is likely happening is that you aren't including one of those headers, but are including, for example, iostream. Standard library headers are permitted to cause other headers to get included as well, and some implementations' iostream headers do exactly this, but not all. You shouldn't rely on it. If you use EOF, add an explicit include for the appropriate header in your own code. (Even if it isn't your code, which it isn't in this case, the modification required in the source code is the same.)

EOF在stdio中定义。h / cstdio。可能发生的情况是,您不包括其中一个头文件,而是包括,例如,iostream。标准的库头也允许包含其他头,一些实现的iostream头也可以做到这一点,但不是全部。你不应该依赖它。如果您使用EOF,请在您自己的代码中为适当的头添加一个显式的包含。(即使不是您的代码(在本例中不是),源代码所需的修改也是一样的。)