NetBSD Problem Report #6942
Received: (qmail 19981 invoked from network); 5 Feb 1999 00:17:01 -0000
Message-Id: <199902050016.SAA03874@guild.plethora.net>
Date: Thu, 04 Feb 1999 18:16:35 -0600
From: seebs@plethora.net
Sender: seebs@guild.plethora.net
Reply-To: seebs@guild.plethora.net
To: gnats-bugs@gnats.netbsd.org
Subject: sys/param.h defines "MAX" and "MIN"
X-Send-Pr-Version: 3.95
>Number: 6942
>Category: lib
>Synopsis: sys/param.h defines "MAX" and "MIN"
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 04 16:20:00 +0000 1999
>Closed-Date: Tue Mar 09 21:18:23 +0000 1999
>Last-Modified: Tue Mar 09 21:24:05 +0000 1999
>Originator: Peter Seebach
>Release: 1.3.3
>Organization:
>Environment:
System: NetBSD binder.fleet.plethora.net 1.3.3 NetBSD 1.3.3 (BINDER) #0: Thu Jan 28 08:16:10 PST 1999 root@binder.fleet.plethora.net:/usr/src/sys/arch/i386/compile/BINDER i386
>Description:
<sys/param.h> provides definitions of "MAX" and "MIN".
This is wrong.
These macros are in user namespace, and some programs (e.g. "crossfire")
want to define them.
If we want to use these macros, we should hide them properly.
>How-To-Repeat:
#define MAX 23
#include <sys/param.h>
>Fix:
>Release-Note:
>Audit-Trail:
From: woods@most.weird.com (Greg A. Woods)
To: seebs@guild.plethora.net
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/6942: sys/param.h defines "MAX" and "MIN"
Date: Fri, 5 Feb 1999 14:28:52 -0500 (EST)
[ On Thursday, February 4, 1999 at 18:16:35 (-0600), seebs@plethora.net wrote: ]
> Subject: lib/6942: sys/param.h defines "MAX" and "MIN"
>
> >Description:
> <sys/param.h> provides definitions of "MAX" and "MIN".
>
> This is wrong.
It might be "wrong" in the strict sense, but it's been this way forever
on almost all variants of UNIX.
Some programs may be tripping over things like this more recently
because more and more systems slurp up <sys/param.h> whithout the
programmer's knowledge. Every time I've ever written code that
knowledgably includes <sys/param.h> I've been forced to deal with
namespace clashes between the kernel's namespace and my own
application's namespace.
I think the real problem is this recursive inclusion of <sys/param.h>.
I don't think headers that normally are only used to define kernel
parameters and data structures should need to worry about "cluttering"
up user namespace. They are, after all, defining the namespace for a
program that is normally isolated in its own sense. Any application
which explicitly includes a file from <sys/> should be prepared to deal
with merging of namespace.
If there are any APIs defined in <sys/param.h> then perhaps they should
be moved out so that the kernel is free to define it's own MIN/MAX
macros without worrying about cluttering user-program namespace. Maybe
MIN & MAX should simply be moved out to some other kernel header file so
that applications are free to include <sys/param.h> without getting too
much clutter from the kernel's namespace.
--
Greg A. Woods
+1 416 218-0098 VE3TCP <gwoods@acm.org> <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>
State-Changed-From-To: open->closed
State-Changed-By: kleink
State-Changed-When: Tue Mar 9 13:18:23 PST 1999
State-Changed-Why:
I'm rejecting this PR; if you include <sys/param.h>,
you've basically left the territory of a clean name space defined by any
standard (well, other than the SVID). If your problems occurs due to
erroneous inclusion of <sys/param.h> by a different (standards-defined)
header, I offer to have another look into it and fix the problem, but
if it's an explicit inclusion, I think it should be left alone.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.