Patchwork [1/5] HACKING: add preprocessor rules

login
register
mail settings
Submitter Blue Swirl
Date Aug. 15, 2010, 5:50 p.m.
Message ID <AANLkTikzSMQAZHUW+JPHQY1z14TCV1Zvs8qu=w-JzWM-@mail.gmail.com>
Download mbox | patch
Permalink /patch/61769/
State New
Headers show

Comments

Blue Swirl - Aug. 15, 2010, 5:50 p.m.
Add a new file, HACKING, in order to collect recurring
issues with submitted patches.

Start with preprocessor rules, adapted from libvirt HACKING.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 HACKING |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
 create mode 100644 HACKING
Andreas Schwab - Aug. 15, 2010, 9:27 p.m.
Blue Swirl <blauwirbel@gmail.com> writes:

> +For variadic macros, stick with C99 syntax:
> +
> +#define DPRINTF(fmt, ...)                                       \
> +    do { printf("IRQ: " fmt, ## __VA_ARGS__); } while (0)

That's not C99 syntax, the combination with ## is a gcc extension.  In
C99 you cannot have an empty __VA_ARGS__.

Andreas.
Blue Swirl - Aug. 16, 2010, 6:05 p.m.
On Sun, Aug 15, 2010 at 9:27 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Blue Swirl <blauwirbel@gmail.com> writes:
>
>> +For variadic macros, stick with C99 syntax:
>> +
>> +#define DPRINTF(fmt, ...)                                       \
>> +    do { printf("IRQ: " fmt, ## __VA_ARGS__); } while (0)
>
> That's not C99 syntax, the combination with ## is a gcc extension.  In
> C99 you cannot have an empty __VA_ARGS__.

That's too bad, I picked the example from one of our current macros.
Maybe just s/C99/this/ or perhaps we shouldn't specify any
non-standard syntax.
Anthony Liguori - Aug. 16, 2010, 6:32 p.m.
On 08/16/2010 01:05 PM, Blue Swirl wrote:
> On Sun, Aug 15, 2010 at 9:27 PM, Andreas Schwab<schwab@linux-m68k.org>  wrote:
>    
>> Blue Swirl<blauwirbel@gmail.com>  writes:
>>
>>      
>>> +For variadic macros, stick with C99 syntax:
>>> +
>>> +#define DPRINTF(fmt, ...)                                       \
>>> +    do { printf("IRQ: " fmt, ## __VA_ARGS__); } while (0)
>>>        
>> That's not C99 syntax, the combination with ## is a gcc extension.  In
>> C99 you cannot have an empty __VA_ARGS__.
>>      
> That's too bad, I picked the example from one of our current macros.
> Maybe just s/C99/this/ or perhaps we shouldn't specify any
> non-standard syntax.
>    

We definitely should discourage the GCC syntax [#define fn(arg...)] as 
it's deprecated by the new C99 syntax.  Very specifically, only the '##' 
is an extension and it's a widely adopted one.

Regards,

Anthony Liguori
Blue Swirl - Aug. 17, 2010, 5:40 p.m.
On Mon, Aug 16, 2010 at 6:32 PM, Anthony Liguori <anthony@codemonkey.ws> wrote:
> On 08/16/2010 01:05 PM, Blue Swirl wrote:
>>
>> On Sun, Aug 15, 2010 at 9:27 PM, Andreas Schwab<schwab@linux-m68k.org>
>>  wrote:
>>
>>>
>>> Blue Swirl<blauwirbel@gmail.com>  writes:
>>>
>>>
>>>>
>>>> +For variadic macros, stick with C99 syntax:
>>>> +
>>>> +#define DPRINTF(fmt, ...)                                       \
>>>> +    do { printf("IRQ: " fmt, ## __VA_ARGS__); } while (0)
>>>>
>>>
>>> That's not C99 syntax, the combination with ## is a gcc extension.  In
>>> C99 you cannot have an empty __VA_ARGS__.
>>>
>>
>> That's too bad, I picked the example from one of our current macros.
>> Maybe just s/C99/this/ or perhaps we shouldn't specify any
>> non-standard syntax.
>>
>
> We definitely should discourage the GCC syntax [#define fn(arg...)] as it's
> deprecated by the new C99 syntax.  Very specifically, only the '##' is an
> extension and it's a widely adopted one.

I'll do s/C99/this C99-like/.

Patch

diff --git a/HACKING b/HACKING
new file mode 100644
index 0000000..e60aa48
--- /dev/null
+++ b/HACKING
@@ -0,0 +1,6 @@ 
+1. Preprocessor
+
+For variadic macros, stick with C99 syntax:
+
+#define DPRINTF(fmt, ...)                                       \
+    do { printf("IRQ: " fmt, ## __VA_ARGS__); } while (0)