Quote:
|
Originally Posted by Alan Anderson
If I recall correctly, K&R page 101 gives the derivation for the "canonical" string copy statement.
Code:
while(*t++ = *s++);
That's part of why I find c such an uncomfortable language to use. It wants me to think like a compiler. It encourages the use of simple shortcuts that a moderately well-designed compiler should be doing for me.
|
hence the reason for the string.h functions in any standards-compliant C distro. MPLAB is far from standards, as it is basically on the bare minimum needed to program a robot (which isn't going to be doing much with strings).
Quote:
My code is full of explicit tests for zero/nonzero. Although I know I could replace
Code:
if ( my_timer == 0 )
with
and get the same job done, I'm a programmer, and I want to be free to focus on the algorithms and let the compiler care about the details of the bits and bytes. Coding can be, and should be, done by machines.
|
i'll agree with you on that - MCC18 is a fairly sucky compiler. there are, however, quite a few C compilers that do perform optimizations such as this. don't blame the language, blame the compiler.
Quote:
|
And don't get me started on how numeric operations are performed using the smallest size that the operands will fit in, leaving me to worry about overflows even if I know the end result of an expression will always fit in the variable I'm putting it in. Oops, too late...
|
again, a fault of MCC18, not C itself.
all in all, most of the faults you described are with this specific implementation of C. Chances are you would find programming for a regular computer with C much nicer.