Reputation: 735
When using dprintf() I'm getting the warning "implicit declaration of dprintf". That tends to mean a necessary file isn't included, but I already included stdio.h, which is supposed to be all that it needs. Is there something else dprintf needs?
Upvotes: 3
Views: 2929
Reputation: 31
You can look up for fprintf()
here.
I ran into the same problem and hence I was forced to run on POSIX based machine, I must changed my code, so fprintf()
is one of (may be) many options I had.
example :
fprintf(stderr,"file not found");
Upvotes: 0
Reputation: 236
The "feature_test_macros" section of the man page explains that to make stdio.h declare dprintf(), you must first #define _POSIX_C_SOURCE 200809L
(or higher) before you #include <stdio.h>
. The reason for this is that dprintf() was not standardized until POSIX.1-2008, but <stdio.h>
needs to continue to work with code written before that, even if that code used its own identifier named "dprintf". (Defining _GNU_SOURCE or _XOPEN_SOURCE would also work on Linux, but _POSIX_C_SOURCE is the best choice for general portability.)
Upvotes: 3
Reputation: 5525
You might need to set some macros. Put on top of the file, before any include
s the following
#define _POSIX_C_SOURCE 200809L
#define _GNU_SOURCE
(One of that would be enough but I don't know the GLibC version you use)
Upvotes: 2