Skip to content

Instantly share code, notes, and snippets.

@mloskot
Last active December 16, 2015 10:29
Show Gist options
  • Select an option

  • Save mloskot/5420642 to your computer and use it in GitHub Desktop.

Select an option

Save mloskot/5420642 to your computer and use it in GitHub Desktop.
Different fileno() return value reported for standard streams in non-console Windows application (i.e. MFC GUI application)
BOOL MyOnInitDialog()
{
int fdi, fdo, fde;
fdi = fileno(stdin);
fdo = fileno(stdout);
fde = fileno(stderr);
#if _MSC_VER < 1700
assert(fdi == -2);
assert(fdo == -2);
assert(fde == -2);
#else
assert(fdi == 0);
assert(fdo == 1);
assert(fde == 2);
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment