View previous topic :: View next topic |
Author |
Message |
Manzo Saita
Joined: 22 Jul 2009 Posts: 5 Location: TKY JPN
|
Function return value can't cast. Help please. |
Posted: Wed Jul 22, 2009 11:51 pm |
|
|
Hello.
I use PCH3.249.
I wrote the following code.
Variable my_float became 0.
And, variable your_float became 5. ( <--- Result of anticipation)
Is this a problem of CCS-C?
Code: | unsigned int32 foo( void )
{
return 5;
}
void main( void )
{
unsigned int32 ui32;
float my_float, your_float;
my_float = foo(); // or my_float = (float)foo()
your_float = ui32 = foo();
while(1);
} |
_________________ --- Manzo Saita --- |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Jul 23, 2009 1:20 am |
|
|
It's apparently a CCS V3.xxx bug. The code is giving correct results in recent V4.095. |
|
![](templates/subSilver/images/spacer.gif) |
Manzo Saita
Joined: 22 Jul 2009 Posts: 5 Location: TKY JPN
|
Thank you! |
Posted: Thu Jul 23, 2009 2:03 am |
|
|
Thank you! I feel much better with that out of the way. ![Surprised](images/smiles/icon_surprised.gif) _________________ --- Manzo Saita --- |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Jul 23, 2009 2:48 am |
|
|
Just tried this on 3.249. Took the code as posted, but added a serial definition, and printed the float values. Compiled for a 16F628, and it happily outputs 5 for both float values.
How are you testing the value?. Looking at the listing, it correctly calls the same conversion function with the same values for both conversions.
I have never heard of a problem here with 3.249.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Jul 23, 2009 5:08 am |
|
|
The bug is present in PCH 3.222 (without using additional printf() statements), it can be seen in assembly listing and MPLAB SIM. I haven't PCH V3.249 installed, but it may the case, that the behaviour is modified when inserting printf(). |
|
![](templates/subSilver/images/spacer.gif) |
|