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

returning float union

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



Joined: 17 Sep 2004
Posts: 133
Location: UK

View user's profile Send private message

returning float union
PostPosted: Fri Apr 22, 2005 6:33 am     Reply with quote

I have got a definition of the following union:
extern union unionFloat
{
float fl;
unsigned char cha[4];
};
extern union unionFloat AvStepsPerMm;
extern union unionFloat AvStepsPerMm_inv;

Then I have got a function:

unsigned float getAvStepsPerMm(void)
{
uchar i;

for (i=0;i<4;i++)
{
if ((AvStepPerMm.cha[i] ^ AvStepPerMm_inv.cha[i]) != 0xFF)
{
systemAlarm(CRITICAL_FLOAT_FAILURE);
while(1);
}
}

return(AvStepsPerMm.fl);
}

I call it here:

readSFlash(0x04, (uchar*)&verify.fl);
if (getAvStepsPerMm() != verify.fl)
{}

I have got the following errors on the "if" statement:
Error [1128] compatible scalar operands required for comparison
Error [1122] scalar operand expected for '!' operator
Error [1117] scalar type expected in 'if' statement
_________________
Alex
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Apr 22, 2005 7:47 am     Reply with quote

Try declaring
Code:
unsigned float getAvStepsPerMm(void)

as
Code:
float getAvStepsPerMm(void)
alexz



Joined: 17 Sep 2004
Posts: 133
Location: UK

View user's profile Send private message

PostPosted: Fri Apr 22, 2005 7:49 am     Reply with quote

Mark wrote:
Try declaring
Code:
unsigned float getAvStepsPerMm(void)

as
Code:
float getAvStepsPerMm(void)



already tried
_________________
Alex
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Apr 22, 2005 7:50 am     Reply with quote

Are you using the CCS compiler? I get an error if I try unsigned but otherwise it compiles just fine.
alexz



Joined: 17 Sep 2004
Posts: 133
Location: UK

View user's profile Send private message

PostPosted: Fri Apr 22, 2005 7:55 am     Reply with quote

Mark wrote:
Are you using the CCS compiler? I get an error if I try unsigned but otherwise it compiles just fine.


Actually C18 at the moment
_________________
Alex
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Apr 22, 2005 7:58 am     Reply with quote

Okay, how do you expect people to help when they assume that you are using CCS compiler!?!?! Mad Why are you asking these questions on the Microchip forum? Good luck and maybe someone else will waste time helping ya, I ain't Exclamation
alexz



Joined: 17 Sep 2004
Posts: 133
Location: UK

View user's profile Send private message

PostPosted: Fri Apr 22, 2005 8:02 am     Reply with quote

Mark wrote:
Okay, how do you expect people to help when they assume that you are using CCS compiler!?!?! Mad Why are you asking these questions on the Microchip forum? Good luck and maybe someone else will waste time helping ya, I ain't Exclamation



Sorry
_________________
Alex
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