From owner-freebsd-hackers Mon Jan 1 09:17:37 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id JAA28011 for hackers-outgoing; Mon, 1 Jan 1996 09:17:37 -0800 (PST) Received: from snoopy.mv.com (snoopy.mv.com [199.125.64.182]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id JAA28004 for ; Mon, 1 Jan 1996 09:17:33 -0800 (PST) Received: (from pw@localhost) by snoopy.mv.com (8.6.12/8.6.9) id JAA21474; Mon, 1 Jan 1996 09:21:14 -0500 Date: Mon, 1 Jan 1996 09:21:14 -0500 From: "Paul F. Werkowski" Message-Id: <199601011421.JAA21474@snoopy.mv.com> To: Bruce Evans Cc: hackers@FreeBSD.ORG Subject: Re: libraries In-Reply-To: <199601010704.SAA25177@godzilla.zeta.org.au> References: <199601010704.SAA25177@godzilla.zeta.org.au> Sender: owner-hackers@FreeBSD.ORG Precedence: bulk >>>>> "Bruce" == Bruce Evans writes: >> So, is present on all systems that have a C >> compiler or just systems with compilers that define the 'unix' >> macro, or just BSD derived systems? Bruce> Of course not. >> Does one need >> #if defined __FreeBSD__ || defined >> __listOfOthersKnownToHaveParam_ .. #include /* >> tests for various flavors of BSD go here */ #endif Bruce> This is impractical. The list would have to have a few Bruce> thousand systems in it, and you wouldn't work on thise Bruce> systems that don't identify themselves. >> Offhand, it looks like the OS dependent feature is hidden in an >> OS dependent file. It seems to me that the compiler ought to >> emit the root feature list in some standard way so that codes >> can have some predictable behaviour. Bruce> This is impractical. The feature list would have to have a Bruce> few thousand flags in it, and wouldn't work on those Bruce> systems that don't support it. Bruce> The correct method to handle this is to generate the Bruce> feature lists on the fly like gnu autoconf does. However, Bruce> this is too much trouble for a port. Just use `#if 0', Bruce> perhaps with a comment, or Bruce> #ifdef Bruce> this_is_unportable_and_I_am_too_lazy_to_make_it_portable Bruce> or the original Bruce> #ifndef __FreeBSD__ Bruce> The latter has the advantage that it is usually spelled Bruce> consistently so you can find it easily. I agree. This is also contrary to the nifty /usr/share/doc/handbook and previous comments in this thread which advise that __FreeBSD__ compiler generated feature should be used only rarely and that the "proper" way to test for BSDism's is to test for the BSD feature, which presupposes that one already knows enough about the environment to include , which looks like the meta-circular screw at work. Testing against __FreeBSD__ then becomes the easiest way to get a port running, and also leads to possible misuse unless one has experience or reference into what features do or do not exist on the various other OS flavors. Mods then get maybe sent back to the original author who is asked to merge in changes he probably cannot test and the circle repeats. This all results in a horrific nest of ifdefs that are near impossible to fathom. Well, sorry to protract this discussion into beating something that is already dead. It probably belongs in 'ports' and not 'hackers' anyway. Best wishes for a pro$perou$ new year to all. Paul