From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6302 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Convert some is* macros to inline functions Date: Mon, 13 Oct 2014 14:06:22 -0400 Message-ID: <20141013180622.GE32028@brightrain.aerifal.cx> References: <20141013142020.GA26828@zx-spectrum.accesssoftek.com> <1413210914.4885.1174.camel@eris.loria.fr> <20141013180056.GA28588@zx-spectrum.accesssoftek.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1413223604 25131 80.91.229.3 (13 Oct 2014 18:06:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 13 Oct 2014 18:06:44 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6315-gllmg-musl=m.gmane.org@lists.openwall.com Mon Oct 13 20:06:37 2014 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 1Xdk0x-00081N-Pv for gllmg-musl@plane.gmane.org; Mon, 13 Oct 2014 20:06:35 +0200 Original-Received: (qmail 11873 invoked by uid 550); 13 Oct 2014 18:06:35 -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 11862 invoked from network); 13 Oct 2014 18:06:35 -0000 Content-Disposition: inline In-Reply-To: <20141013180056.GA28588@zx-spectrum.accesssoftek.com> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6302 Archived-At: On Mon, Oct 13, 2014 at 09:00:56PM +0300, Sergey Dmitrouk wrote: > On Mon, Oct 13, 2014 at 07:35:14AM -0700, Jens Gustedt wrote: > > Am Montag, den 13.10.2014, 17:20 +0300 schrieb Sergey Dmitrouk: > > In section 7.1.4 the C standard explicitly says: > > > > > Any function declared in a header may be additionally implemented > > > as a function-like macro defined in the header, ... > > Didn't look there, you're right. I was checking description of headers > instead. > > > > Please find the attached patch that proposes replacing these macros > > > with inline functions. > > > > I don't think that this is necessary. > > > > They only advantage of inline functions, here would be that the > > conversion of the arguments would be done with implicit conversions > > instead of casts. (For the macros this could be achieved by using > > compound literals instead of casts, but well...) > > It's not necessary for C (as I know now), but it's required by ะก++ > standard in 17.6.1.2: > > > Names that are defined as functions in C shall be defined as functions > > in the C++ standard library. 175) > > > 175) This disallows the practice, allowed in C, of providing a masking > > macro in addition to the function prototype. The only way to achieve > > equivalent inline behavior in C++ is to provide a definition as an > > extern inline function. > > Current headers do not conform to C++ when included as , and > that's what I'm trying to fix. > > Would you consider a version that uses inline functions only when > __cplusplus is defined? There is already 'extern "C"', so I guess it > makes sense. Suppressing the macros for C++ would be acceptable if this is required (it's not clear to me; my understanding was that it's only required for the headers, not the <______.h> ones, and that the wrappers for the former already take care of removing the macros). The external inline functions are probably not acceptable; there are all sorts of ugly issues with extern inline function support that I don't want to deal with. Rich