#include <stdio.h>
#include <windows.h>
using namespace std;
int main() {
char s[] = "Hello\n";
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
unsigned long cChars;
WriteConsole(stdout, s, lstrlen(s), &cChars, NULL);
}
result: error: declaration of '_iob' as array of references
but when I comment out stdio.h, it compiles ok. What’s wrong here ?
Compiler is MinGW.
Depending on the platform, stdout is probably a macro, so better not use that name. Replace
with
and then
stdout is defined in stdio.h, that’s why it fails only when this file is included. But to be safe, never use that name for any self-defined variable.