From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1793 Path: news.gmane.org!not-for-mail From: Gregor Richards Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: Best bikeshed ever (feature test macros) Date: Wed, 29 Aug 2012 13:17:48 -0400 Message-ID: <503E4EBC.5040608@purdue.edu> References: <20120824214138.GA17792@brightrain.aerifal.cx> <20120829073442.66c72367@gmail.com> <20120829134939.GS27715@brightrain.aerifal.cx> <503E20B9.7060705@purdue.edu> <20120829144347.GU27715@brightrain.aerifal.cx> <20120829152319.GW27715@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1346260685 30399 80.91.229.3 (29 Aug 2012 17:18:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Aug 2012 17:18:05 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1794-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 29 19:18:05 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1T6ltz-0000Xq-HB for gllmg-musl@plane.gmane.org; Wed, 29 Aug 2012 19:18:03 +0200 Original-Received: (qmail 19548 invoked by uid 550); 29 Aug 2012 17:18:01 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 19516 invoked from network); 29 Aug 2012 17:18:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: <20120829152319.GW27715@brightrain.aerifal.cx> X-PMX-Version: 5.5.9.388399 X-PerlMx-Virus-Scanned: Yes Xref: news.gmane.org gmane.linux.lib.musl.general:1793 Archived-At: On 08/29/2012 11:23 AM, Rich Felker wrote: > For example, if you want the kitchen > sink on some (most?) BSDs, the only way to get it is to omit all > feature test macros entirely I need to echo this sentiment, because it's important: If you use only POSIX, then feature test macros are great. They behave the same everywhere and give you exactly what you want. If you use ANY EXTENSIONS WHATSOEVER, then adding feature test macros WILL ASSUREDLY BREAK YOUR PROGRAM on some libc. The implementation is simply not consistent. The fact is, that if you want your program to be portable, but it requires extensions (this is not an oxymoron), then the proper way to go is to check for those extensions with something like autoconf, and then never ever set feature test macros. It's probably even worse than you think: The only way to figure out where or how it breaks your code is to try it everywhere. Thought setting _BSD_SOURCE was enough? Nope, you'll need at least __BSD_VISIBLE (which you're not supposed to touch), __EXTENSIONS__ and _DARWIN_C_SOURCE. If the feature test macro does not correspond to a standard, then it is a very effective way to shoot yourself in the foot. Just to make this perfectly clear: If you are writing a portable program that, under any circumstances, uses some extension beyond POSIX, then adding feature test macros will break your code. The code out there without feature test macros is not broken; it's portable. You can whine and moan about that state of affairs as much as you want, but if you actually want software to work on musl /and/ some other libc, then you must support this configuration. (Please note that, in direct response to the statement I'm quoting, FreeBSD and Solaris are the only libcs I know of at this time that provide no way beyond hacks to get “the kitchen sink” back after setting feature test macros. You need to set at least _BSD_SOURCE, _SVID_SOURCE and _DARWIN_C_SOURCE to get the kitchen sink back on those that do support nonstandard feature test macros.) With valediction, - Gregor Richards