Hi Ramus, On Fri, Aug 31, 2018 at 11:49 PM, Rasmus Villemoes <li...@rasmusvillemoes.dk> wrote: > On 2018-08-31 19:05, Miguel Ojeda wrote: >> The attribute syntax optionally allows to surround attribute names >> with "__" in order to avoid collisions with macros of the same name >> (see https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html). >> >> This homogenizes all attributes to use the syntax without underscores. > > At the risk of bikeshedding, why not the other way around, exactly > because of what you write above? We have convenience macros anyway, so > those verbose leading/trailing underscores would only be in compiler*.h, > and some of the attribute names are common words that can appear as > #defines. E.g. error is defined > drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c ; if that used a > BUILD_BUG_ON somewhere, the > > #define __compiletime_error(message) __attribute__((error(message))) > > would break.
Indeed, if we are afraid of such cases, we should go with the __name__ syntax. I was trying to go first for the "cleanest"/simplest way first, considering no one should be defining many such macros as "error" (and in lower case, at that). But indeed, good catch! Grepping for those in compiler_attributes.h (which, as you point out, are not all of them) yields: arch/parisc/boot/compressed/misc.c:#define malloc malloc_gzip include/linux/decompress/mm.h:#define malloc(a) kmalloc(a, GFP_KERNEL) lib/inflate.c:#define malloc(a) kmalloc(a, GFP_KERNEL) include/linux/compiler_types.h:#define noinline_for_stack noinline include/linux/raid/pq.h:#define noinline __attribute__((noinline)) tools/include/linux/compiler.h:#define noinline arch/mips/sgi-ip27/ip27-reset.c:#define noreturn while(1); /* Silence gcc. */ Cheers, Miguel