Browse Source

Some user header files may define an abs macro which will cause a

syntax error if the #define happens before stdlib.h is included.
If abs is #defined, #undef and issue a warning.  This is similar
to what Tru64 UNIX does and is effectively the same as what happens
on Solaris (though on Solaris the real abs() is a macro).
OPENBSD_3_1
millert 23 years ago
parent
commit
d212774fe6
1 changed files with 17 additions and 1 deletions
  1. +17
    -1
      src/include/stdlib.h

+ 17
- 1
src/include/stdlib.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: stdlib.h,v 1.17 2002/02/17 19:42:21 millert Exp $ */
/* $OpenBSD: stdlib.h,v 1.18 2002/02/20 18:11:04 millert Exp $ */
/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
/*-
@ -92,6 +92,15 @@ typedef struct {
#include <sys/cdefs.h>
/*
* Some header files may define an abs macro.
* If defined, undef it to prevent a syntax error and issue a warning.
*/
#ifdef abs
#undef abs
#warning abs macro collides with abs() prototype, undefining
#endif
__BEGIN_DECLS
__dead void abort(void);
int abs(int);
@ -116,8 +125,12 @@ void *realloc(void *, size_t);
void srand(unsigned);
double strtod(const char *, char **);
long strtol(const char *, char **, int);
long long
strtoll(const char *, char **, int);
unsigned long
strtoul(const char *, char **, int);
unsigned long long
strtoull(const char *, char **, int);
int system(const char *);
/* these are currently just stubs */
@ -156,6 +169,8 @@ char *l64a(long);
void cfree(void *);
#ifndef _GETOPT_DEFINED_
#define _GETOPT_DEFINED_
int getopt(int, char * const *, const char *);
extern char *optarg; /* getopt(3) external variables */
extern int opterr;
@ -164,6 +179,7 @@ extern int optopt;
extern int optreset;
int getsubopt(char **, char * const *, char **);
extern char *suboptarg; /* getsubopt(3) external variable */
#endif /* _GETOPT_DEFINED_ */
int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));


Loading…
Cancel
Save