Results 1 to 3 of 3
Hi,
While compiling my C program, I am getting warning as "warning: implicit declaration of function pread". I have included unistd.h header file(which contains pread function declaration). I also tried ...
- 11-29-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 4
warning: implicit declaration of function "pread"
Hi,
While compiling my C program, I am getting warning as "warning: implicit declaration of function pread". I have included unistd.h header file(which contains pread function declaration). I also tried adding macro _XOPEN_SOURCE before including unistd.h header file, as it was suggested in one of the posts, but still I am getting the same warning. I tried to find answers on google, but I was unable to resolve it.
Though I am getting correct result even with warning, I want to rectify it.
Any help is appreciated. Thanks in advance.
-Pooja.
- 11-29-2011 #2Just Joined!
- Join Date
- Nov 2011
- Location
- New York, NY, USA
- Posts
- 1
Pooja, I just ran into the identical problem. In fact, mine was worse, because I was modifying GCC, whose build system uses -Werror; I didn't want to muck around in the Makefiles, etc., more than necessary. Are you using Ubuntu, by any chance? Anyway, I happened to get a solution (I think):
My man page, like yours, only mentions defining _XOPEN_SOURCE as 500. But it only seems to work if I have both this and the _BSD_SOURCE definition. The order does not seem to matter. Please let me know whether this works for you. Perhaps it's worth a bug report about the man page.Code:#define _XOPEN_SOURCE 500 #define _BSD_SOURCE #include <unistd.h>
- 11-30-2011 #3Just Joined!
- Join Date
- Mar 2011
- Posts
- 4
Thanks Amittai for replying.
I tried adding both the flags _XOPEN_SOURCE and _BSD_SOURCE as per your suggestion, but then it gives warning saying
warning: "_BSD_SOURCE" redefined" /usr/include/features.h:175:1: warning: this is the location of the previous definition
with original warnings of implicit declaration of pread.
I am using CentOS - 5.6 (final).
-Pooja.


Reply With Quote
