Deep question for the REAL C GURU's out there ...
Alma J Wetzker
almaw
Thu Feb 24 11:06:11 PST 2005
Ben Duncan wrote:
>
>
> Roger Oberholtzer wrote:
>
>> On Thu, 2005-02-24 at 15:58, Ben Duncan wrote:
>>
> <SNIP>
>
>>
>> update the value: ++(ptr->counter)
>>
>> update the pointer: (++ptr)->counter
>>
>> get a new hobby: ++ptr->counter
>>
>
> Ohh .. that one stings. But then again, precedence of the operators.
>
> Between you and Kurt and the realization that those using SLAG are
> going to be MORE Applications programmers, I am going to chose
> CLARITY and lots of it, over laziness.
>
>
>> It is another one of my quirks. I explicitly specify ordering. Never
>> trust a compiler more than you need to.
>>
>> <SNIP>
>>
>
FWIW, I have found that most optimizing compilers can do a better job with
clear code than they can with the other sort. MORAL, Unless you can write
better assembler code than a good optimizing compiler, make your code clear.
As far an the coding style issues are concerned, It is best practice to code
like the rest of the programs in the library you are using. If you are making
your own code base, you get to set the style.
My preference for struct's is based on how many places will they be used. If
you will make several changes or share them between files, do the typedef
thing and declare the actual structs in the later code, that way, you can
easily move the typedefs to an include file. If you will never use the
structs outside of the current file, it really doesn't make a difference how
you declare them, because the compiler is good.
These opinions have an aroma not noticeably different from any other (given
their source), but I attempted to use logic! ;)
-- Alma
More information about the Linux-users
mailing list