"David Bourgeois" <[EMAIL PROTECTED]> writes:

[...]
> What about defines, enums, etc., you'd put the comment/description of
> define_1 on the right or on the line before?
> enum my_enum {
>     define_1,
>     define_2,
> }

For enums, I write the comment about the enum itself above it and the
comments describing each enum member (not always necessary, sometimes
the names speak for themselves) to the right of the member. Using dox
comments:

    /** My very nice enum */
    enum my_enum {
        define_1,  /**< Blah blah 1 */
        define_2,  /**< Blah blah 2 */
    };

>>> There's the same for function calls, should we do
>>>      void my_long_function_call(parameter_1, parameter_2,  parameter_3,
>>>                                 parameter_4)
>>> or
>>>      void my_long_function_call(parameter_1, parameter_2,  parameter_3,
>>>              parameter_4)
>>
>> Both styles are ok and I have used both. Depends on the coding style
>> conventions. (For the second one, it is advised to indent the second
>> part with two indentation levels.)
>>
>> I prefer the first one though, as I find it a bit cleaner (and it is
>> how Emacs indents C by default ;-)).
>
> vi defaults to the second, I think we'll never agree on this ;-)

So, which style to you choose ? (the second one, I bet) I'll set up my
Tuxdroïd mode to use that style.

[...]
> Looking into this again (to find you some pointers), I'm not sure my
> previous statement was right, I'll have to do some tests again. This
> was  discussed on the avrlibc mailing list some time ago. But what I'm
> sure now  is that a swicth can be very efficient if all cases are
> incremental as it  can use a lookup table, otherwise it generates a
> if-then-else sequence  which takes much more space. In i2c.c (tuxcore)

Yeah, I have some memories about lookup tables being generated for
small switches on contiguous values. Never bothered to look at the
generated code, though.

> I created the lookup table  manually as the compiler never wanted to
> do it, and I saved more than 100  bytes doing so.
> I'll let you know if I find something interesting.

Okay, thanks.

[...]
> Yep, my fault, I was probably asleep at the time I wrote that. I'll
> fix  it, write it 100 times and go to sleep without eating ;-)

We'd rather add the things we discuss here to the coding style
guidelines when we're set :-)

        Damien

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
tux-droid-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-user

Reply via email to