portability touch-up #2

Bernhard Fischer rep.nop at aon.at
Fri May 26 15:19:15 PDT 2006


On Fri, May 26, 2006 at 11:40:54PM +0200, Peter S. Mazinger wrote:
>On Fri, 26 May 2006, Bernhard Fischer wrote:
>
>> This is the rest of the initial diff.
>> 
>> These bits are needed to be able to configure busybox with a non-gcc
>> C-compiler on a non-linux box.
>> 
>> Just for reference..
>
>s/getopt.h/unistd.h/ as of SuSv3

Ouch. You're right.

#ifdef  __USE_POSIX2
/* Get definitions and prototypes for functions to process the
   arguments in ARGV (ARGC of them, minus the program name) for
   options given in OPTS.  */
# define __need_getopt
# include <getopt.h>
#endif

for glibc; resp.:

/*
 * POSIX requires that certain values be included in unistd.h.  It also
 * requires that when _POSIX_C_SOURCE is defined (>= 1) only those 
 * standard specific values are present.  This header includes all the
 * POSIX
 * required entries.
 */

#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 1)
/* Symbolic constants for the "lseek" function: */

#include <sys/seek.h>
#include <getopt.h>

/***AAB-XPG4*** must protect from XPG4 ***/
#ifdef _OSF_SOURCE
extern char **environ;          /* Environment description variable */
/* forward declaration for bindresvport() */
struct sockaddr_in;
#endif /*OSF_SOURCE*/

We still have some direct getopt users, so they ought to include
getopt.h themselves; The getopt_ulflags users which don't use optind
nor optarg could (and should) thusly of course drop that include.
Thanks for the hint.


More information about the busybox mailing list