Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STDIN_FILENO undeclared in Windows

I have some code using the select function that compiles and runs fine in Linux. But I'm trying to port it to Windows and am getting this error I don't know how to deal with. It says

STDIN_FILENO: undeclared identifier

I haven't been able to come up with or find any solution for this. Is there a way to make STDIN_FILENO work in Windows?

like image 609
Sterling Avatar asked Nov 23 '12 15:11

Sterling


3 Answers

MSDN suggests the use of _fileno(stdin), where _fileno is declared in <stdio.h>.

Note, however:

If stdout or stderr is not associated with an output stream (for example, in a Windows application without a console window), the file descriptor returned is -2. In previous versions, the file descriptor returned was -1. This change allows applications to distinguish this condition from an error.

like image 131
200_success Avatar answered Nov 07 '22 19:11

200_success


STDIN_FILENO is a definition of standard POSIX,

Try 0 !

like image 25
b3h3m0th Avatar answered Nov 07 '22 19:11

b3h3m0th


I apologize for answering so late, but I have solved this problem adding unistd.h on gcc compiler. So, try to add

#include <unistd.h>

Useful reference link.

like image 1
msc Avatar answered Nov 07 '22 20:11

msc