On Sun, Dec 13, 2009 at 09:53:42PM +0100, Carsten Breuer wrote:
> What I dislike most:
>
> Missing brackets:
>
> if (FOO_BAR)
> do_something
>
> It should be
>
> if (FOO_BAR)
> {
> do:something
> }
>
> because if do_something is defined like follows:
>
> #define do_something a=10; b = 20;
>
> Then the resulting code is really:
>
> if (FOO_BAR)
> {
> a=10;
> }
> b = 20;
>
> Lint would complain about this.
You could also argue that the do_something definition is buggy, since
it's not one statement.
E.g. the Linux kernel takes this stance, and wraps such macros in do
{ } while (0) blocks:
#define local_irq_enable() \
do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
#define local_irq_disable() \
do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development