[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie: how to handle different prototypes?

From: gnoop
Subject: Newbie: how to handle different prototypes?
Date: Wed, 22 Jun 2005 13:17:02 -0700

I have a basic question that I couldn't find in the info docs or the goat book. 
 What's the right way to deal with a prototype for a system library function 
that differs between platforms?  I know how to check for headers and libraries, 
but don't know what the autotools way is to get around different prototypes.

For example, on linux the scandir prototype is:

       int scandir(const char *dir, struct dirent ***namelist,
              int(*select)(const struct dirent *),
              int(*compar)(const struct dirent **, const struct dirent **));

and on darwin it's:

     scandir(const char *dirname, struct dirent ***namelist,
         int (*select)(struct dirent *),
         int (*compar)(const void *, const void *));

I.e. the const is missing from darwin's 3rd parameter.  Not knowing which 
systems implement which headers seems problematic.  In any case, do I redefine 
scandir and know that the linker will still find it or add a const to my own 
select() prototype depending on the system?  Or is there a standard macro for 
this that I couldn't find?

Thanks in advance.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]