>A strength of C is that the compiler is supposed to protect you from doing it when you don't mean to, as in the above case. An "implicit" cast is one that you don't write but that happens anyway to match up the types. These can be benign (such as treating an 8-bit integer as a 16-bit integer when necessary), wasteful and confusing (such as treating an 8-bit integer as a 16-bit integer when required by the language definition but not strictly necessary), or dangerous and probably wrong, as in your case. lcd_putc(pgm_read_byte_near(&(BootString[i]))); So this is dangerous? The way I read this now, is: Take the address of the ith element of BootString and pass that to pgm_read_byte_near. Pass to lcd_put_c the byte returned by pgm_read_byte_near. > With decades of high-level language programming experience behind me, I have a policy of avoiding implicit casts. In other words, I write my casts out in the code. Then, I can see what the compiler is going to do because I'm telling it exactly. These are called "explicit" casts. You might want to consider this. Sounds like a very good idea. > I should also point out (and by the length of my replies, I'm sure you've figured out that I'm between jobs right now) that the parentheses around BootString[i] are not actually necessary. I believe in forcing the order of operations. -- There is no computer problem which cannot be solved by proper application of a sufficiently large hammer.
Message
Re: [AVR-Chat] Re: WinAVR / GCC question re Stack
2009-03-25 by David VanHorn
Attachments
- No local attachments were found for this message.