CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Float and constant comparison : what is wrong ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dynamitron



Joined: 18 Mar 2009
Posts: 38

View user's profile Send private message

Float and constant comparison : what is wrong ?
PostPosted: Sat Jun 13, 2009 9:31 am     Reply with quote

I try to compare a float to a constant (see code below) and I got an error that says that a paren is missing and in fact it is not.

What is wrong ?

Thanks,
D.

Code:
   
float temperature [5];
int8 temperature_haut;
      
if (temperature [0]>25.0)
   (      
     temperature_haut = (int)10 * temperature [0];
   )




Code:

Executing: "C:\Program files\Picc\CCSC.exe" +FH "rtc_ow.c" I+="C:\Program Files\PICC\Devices"  +DF +LN +T +A +M +Z +Y=9 +EA
*** Error 58 "rtc_ow.c" Line 799(60,61): Expecting a close paren
*** Error 51 "rtc_ow.c" Line 800(6,7): A numeric expression must appear here
      2 Errors,  0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Sat Jun 13 17:11:08 2009


Last edited by dynamitron on Sat Jun 13, 2009 10:08 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jun 13, 2009 10:03 am     Reply with quote

Quote:
float temperature [0];

You have declared an array with 0 elements. That's not allowed.
It gives this error:
Quote:
*** Error 45 "pcm_test.c" Line 9(20,21): Subscript out of range

Please get book on the C language.
dynamitron



Joined: 18 Mar 2009
Posts: 38

View user's profile Send private message

PostPosted: Sat Jun 13, 2009 10:08 am     Reply with quote

yeah, I know that.
In fact I summarized the code for the post and I made a mistake in the transcript.
The post is corrected now and the question is still there.

D.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jun 13, 2009 10:14 am     Reply with quote

Quote:
if (temperature [0]>25.0)
(
temperature_haut = (int)10 * temperature [0];
)

You're using parens and you should be using braces.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group