View previous topic :: View next topic |
Author |
Message |
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
returning float union |
Posted: Fri Apr 22, 2005 6:33 am |
|
|
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
|
|
Posted: Fri Apr 22, 2005 7:47 am |
|
|
Try declaring
Code: | unsigned float getAvStepsPerMm(void)
|
as
Code: | float getAvStepsPerMm(void)
|
|
|
|
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
|
Posted: Fri Apr 22, 2005 7:49 am |
|
|
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
|
|
Posted: Fri Apr 22, 2005 7:50 am |
|
|
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
|
|
Posted: Fri Apr 22, 2005 7:55 am |
|
|
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
|
|
Posted: Fri Apr 22, 2005 7:58 am |
|
|
Okay, how do you expect people to help when they assume that you are using CCS compiler!?!?! Why are you asking these questions on the Microchip forum? Good luck and maybe someone else will waste time helping ya, I ain't |
|
|
alexz
Joined: 17 Sep 2004 Posts: 133 Location: UK
|
|
Posted: Fri Apr 22, 2005 8:02 am |
|
|
Mark wrote: | Okay, how do you expect people to help when they assume that you are using CCS compiler!?!?! Why are you asking these questions on the Microchip forum? Good luck and maybe someone else will waste time helping ya, I ain't |
Sorry _________________ Alex |
|
|
|