declaration Q

Discussion in 'C Programming' started by CptDondo, Dec 8, 2005.

  1. CptDondo

    CptDondo Guest

    I've got an issue that I can't figure out.... It has to do with a
    compiler warning:

    warning: passing arg 3 of `scandir' from incompatible pointer type

    Now scandir is declared in dirent.h:

    extern int scandir (__const char *__restrict __dir,
    struct dirent ***__restrict __namelist,
    int (*__selector) (__const struct dirent *),
    int (*__cmp) (__const void *, __const void *));

    I am calling it as follows:

    n = scandir ("/data/pictures", &namelist, ysfilter, alphasort);

    and my 3rd argument (ysfilter) is declared as follows:

    int ysfilter (struct dirent *dir);

    The 4th argument is

    extern int alphasort (__const void *__e1, __const void *__e2)
    __THROW __attribute_pure__;

    so they should be both the same....

    I must be blind.... Or I'm missing something really obvious.

    Why am I getting a warning?
     
    CptDondo, Dec 8, 2005
    #1
    1. Advertising

  2. CptDondo

    tedu Guest

    CptDondo wrote:
    > I've got an issue that I can't figure out.... It has to do with a
    > compiler warning:
    >
    > warning: passing arg 3 of `scandir' from incompatible pointer type
    >
    > Now scandir is declared in dirent.h:
    >
    > extern int scandir (__const char *__restrict __dir,
    > struct dirent ***__restrict __namelist,
    > int (*__selector) (__const struct dirent *),
    > int (*__cmp) (__const void *, __const void *));
    >
    > I am calling it as follows:
    >
    > n = scandir ("/data/pictures", &namelist, ysfilter, alphasort);
    >
    > and my 3rd argument (ysfilter) is declared as follows:
    >
    > int ysfilter (struct dirent *dir);


    missing const here.
     
    tedu, Dec 8, 2005
    #2
    1. Advertising

  3. On Thu, 08 Dec 2005 11:02:32 -0800, tedu wrote:

    >> int ysfilter (struct dirent *dir);

    >
    > missing const here.


    DUH! Thanks. I got so focused on the function type that I didn't check
    the args....
     
    Captain Dondo, Dec 9, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    962
  2. Alex Vinokur
    Replies:
    4
    Views:
    595
    Jonathan Turkanis
    Apr 5, 2004
  3. Ovidesvideo
    Replies:
    4
    Views:
    518
    Andrey Tarasevich
    Dec 10, 2004
  4. kelvSYC
    Replies:
    6
    Views:
    7,235
    Richard Herring
    May 17, 2005
  5. Replies:
    4
    Views:
    1,082
    Richard Tobin
    Dec 12, 2006
Loading...

Share This Page