|
Message-ID: <20120413033153.GI7281@brightrain.aerifal.cx> Date: Thu, 12 Apr 2012 23:31:53 -0400 From: Rich Felker <dalias@...ifal.cx> To: musl@...ts.openwall.com Subject: Re: [PATCH] string.h, _BSD_SOURCE, and *index() On Fri, Apr 13, 2012 at 01:52:27PM +1200, Andre Renaud wrote: > On Fri, Apr 13, 2012 at 1:45 PM, Isaac Dunham <idunham@...abit.com> wrote: > > (r)index was X/Open legacy, and has been dropped. The Open Group > > recommended using > > #define index(a,b) strchr((a),(b)) > > #define rindex(a,b) strrchr((a),(b)) > > Which will let us remove two more files if we do it (rindex.c & index.c) > > However, would removing those break the ABI? > > I'm curious about this - what is the general consensus on using > #define to do these kind of translations, versus using static inline > functions, such as: > static inline char *index(const char *s, int c) {return strchr(s, c);} > static inline char *rindex(const char *s, int c) {return strrchr(s, c);} Both are wrong to do in this header, but the static inline definition is even "more wrong". Non-static inline would be okay, but static inline conflicts with the "correct" (albeit removed) declaration of the function and will actively break code that prototypes the function (and can't be removed with #undef). 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.