Find the answer to your Linux question:
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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.

  2. #2
    Just Joined!
    Join Date
    Nov 2011
    Location
    New York, NY, USA
    Posts
    1
    Quote Originally Posted by pooja_kanchan View Post
    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.
    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):

    Code:
    #define _XOPEN_SOURCE 500
    #define _BSD_SOURCE
    #include <unistd.h>
    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.

  3. #3
    Just 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.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •