NetBSD-Bugs archive

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

lib/48187: multiple definitions of same macros in headers



>Number:         48187
>Category:       lib
>Synopsis:       multiple definitions of same macros in headers
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 05 22:00:00 +0000 2013
>Originator:     Justin Cormack
>Release:        6.1 (and cvs)
>Organization:
>Environment:
NetBSD netbsd32.myriabit.eu 6.1 NetBSD 6.1 (XEN3PAE_DOMU) i386
>Description:
There is a set of constants that are defined in multiple places in the NetBSD 
headers, without #ifdefs around either set, so some header combinations 
conflict.

The constants in question are: FLT_DIG, FLT_MIN, FLT_MAX and DBL_DIG, DBL_MIN, 
DBL_MAX.

These are defined (as per C89) via float.h, but actually in sys/float_ieee754.h 
- the definitions here generally use the gcc definitions where available and 
have various cases, plus define the other associated constants that C89 defines.

However these are also defined in /usr/include/i386/limits.h (and, if you 
check, for all other architectures eg /usr/include/amd64/limits.h on amd64, 
plus other architectures if you check the source). These are only protected by 
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) which are obviously often 
defined.

Because these are system headers, the warnings for these redefinitions are 
hidden without -Wsystem-headers (which is not in -Wall); I noticed when cross 
compiling NetBSD, where these were not "system" headers, also if you use 
-nostdinc -I/usr/include where they are not system.

>How-To-Repeat:
test.c:

#include <machine/limits.h>

#include <sys/float_ieee754.h>

int main() {
  return FLT_DIG;
}

compile with
gcc -D_XOPEN_SOURCE=500 -D_NETBSD_SOURCE -Wall -Werror -Wsystem-headers test.c

Note you need -Wsystem-headers or it will be hidden by default. However this is 
an issue when cross compiling parts of NetBSD libc, in particular libc/gdtoa 
and libm as these include float.h as these are not being used as system headers 
when cross compiling. Plus it is a bug even if this warning is not a default, 
just less visible.


>Fix:
Remove FLT_DIG from limits.h and include float.h instead where needed.



Home | Main Index | Thread Index | Old Index