Question

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

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.

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

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

GCC version on centOS:

 4.8.1 20130715

GCC version in Cygwin

 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.

Was it helpful?

Solution

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.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top