NetBSD Problem Report #48187

From  Thu Sep  5 21:57:06 2013
Return-Path: <>
Received: from ( [])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "", Issuer "Postmaster" (verified OK))
	by (Postfix) with ESMTPS id 9430670F1C
	for <>; Thu,  5 Sep 2013 21:57:06 +0000 (UTC)
Message-Id: <>
Date: Thu,  5 Sep 2013 21:57:04 +0000 (UTC)
Subject: multiple definitions of same macros in headers
X-Send-Pr-Version: www-1.0

>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)
NetBSD 6.1 NetBSD 6.1 (XEN3PAE_DOMU) i386
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.


#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.

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

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.