#define stderr (__iob[2]) 

Stream destined for error output. Unless specifically assigned, identical to stdout.

If stderr should point to another stream, the result of another fdevopen() must be explicitly assigned to it without closing the previous stderr (since this would also close stdout).