|
Message-ID: <20141013180622.GE32028@brightrain.aerifal.cx> Date: Mon, 13 Oct 2014 14:06:22 -0400 From: Rich Felker <dalias@...c.org> To: musl@...ts.openwall.com Subject: Re: [PATCH] Convert some is* macros to inline functions 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 <header.h>, 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 <c_____> 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.