On Thu, Jun 11, 2020 at 01:03:46PM -0600, Theo de Raadt wrote: > Theo de Raadt <dera...@openbsd.org> wrote: > > > sensiblehue <sensible...@firemail.cc> wrote: > > > > > On Thu, Jun 11, 2020 at 03:08:01PM +0200, Marc Espie wrote: > > > > On Thu, Jun 11, 2020 at 04:37:34AM +0000, sensiblehue wrote: > > > > > Hello, > > > > > I was wondering why OpenBSD doesn't have a `__printflike' macro in > > > > > <sys/cdefs.h>? FreeBSD, NetBSD, and DragonflyBSD have it and it's also > > > > > available from libbsd on Linux. > > > > > Personally I think it's cleaner and just as portable if not more > > > > > portable, because some compilers don't support `__attribute__'. > > > > > > > > > > > > What compilers ? > > > > > > GCC < v2.5 and non GNU C compilers, though I see now that OpenBSD > > > defines it to nothing in that case. > > > > Ah, so it does actually work fine, unlike what you originally claimed.
Yes, I should've done more research beforehand. > > > > > > > To be honest I'm mostly suggesting __printflike because I want to use it > > > in my own code and still have it compile on OpenBSD without an #ifdef, > > > but it would also make software from other BSDs easier to port. > > > > We are using the attribute mechanism directly in a way that works on > > all modern (10 years?). > > > > Intentionally. > > Let me reiterate why it is used directly. You probably understand, but > I'm not sure you see the value. > > 1. If the compiler supports attributes but does not know this one, the > code compiles, the special handling isn't done, and everything works. > > 2. If the compiler supports attributes but and knows it, the special handling > is performed, and everything works. > > 3. If the compiler is so old that it doesn't handle unsupported attributes, > go use a different (new) compiler. > Fair enough, if __attribute__ has worked for so many years I agree portability isn't a concern. I asked about __printflike because I found it unusual that other major BSDs have it and OpenBSD doesn't, despite using macros like __dead, __unused, etc. If I understood correctly, the existence of those macros is merely a convenience and not an intentional effort for portability with the other BSDs. In that case it was wrong to assume OpenBSD should have it. > You say you want to use an old compiler which doesn't handle unknown > attributes? No, just pointing out an edge case. > How will you cope with all the operating systems which lack the #define > you request? *BSD is the only operating system worth writing code for. :)