View Single Post
  #3   Spotlight this post!  
Unread 13-01-2004, 09:32
john atwood john atwood is offline
Registered User
#0997 (Zip Ties and Electrical Tape)
 
Join Date: Dec 2002
Location: Corvallis, OR
Posts: 1
john atwood is an unknown quantity at this point
Re: Whacky C Complier behavior

Quote:
Originally Posted by Mike Betts

2 issues here...

You are doing an implicit initialization. Never a good idea in an embedded system.

Make it:

int InitFoo;

for your declaration and then

InitFoo = (100 * 5);

in your initialization routine.

Secondly (IMHO), you really do not want to do floating point... I have posted about this in other threads.

Good luck.

The initialization looks pretty explicit to me.
Also, why waste code space and start up time
doing math the compiler can do.

The wacky behavior is a feature, where C18 intentionally departs from ISO standard behavior
for efficiency reasons. See section 2.7.1 of the C18 users guide.

To change the behavior, use the -Oi command line option, which can be set in MPLAB under Project->Build Options->Project->(tab)MPLAB C18->(check)Enable Integer Promotions.


John

Last edited by john atwood : 13-01-2004 at 09:37.