How to fix C error 'stderr undeclared'

Problem:

You have C code like

main.c
fprintf(stderr, "test");

but when you try to compile it you see an error message like

error_message.txt
/home/uli/myproject/main.c:9:25: error: ‘stderr’ undeclared (first use in this function)
                 fprintf(stderr, "test");

Solution

Add

stdio_include.c
#include <stdio.h>

at the top of the source file where the error occured. Including stdio.h will include symbols like printf, fprintf, stdin, stdout and stderr.


Check out similar posts by category: Allgemein