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 support@ccsinfo.com

Function return value can't cast. Help please.

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



Joined: 22 Jul 2009
Posts: 5
Location: TKY JPN

View user's profile Send private message Visit poster's website

Function return value can't cast. Help please.
PostPosted: Wed Jul 22, 2009 11:51 pm     Reply with quote

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 ---
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Jul 23, 2009 1:20 am     Reply with quote

It's apparently a CCS V3.xxx bug. The code is giving correct results in recent V4.095.
Manzo Saita



Joined: 22 Jul 2009
Posts: 5
Location: TKY JPN

View user's profile Send private message Visit poster's website

Thank you!
PostPosted: Thu Jul 23, 2009 2:03 am     Reply with quote

Thank you! I feel much better with that out of the way. Surprised
_________________
--- Manzo Saita ---
Ttelmah
Guest







PostPosted: Thu Jul 23, 2009 2:48 am     Reply with quote

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
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Jul 23, 2009 5:08 am     Reply with quote

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().
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