Hy guys
I´m using CW6.2 C++ in a QE128 design, wich is about my post here...
I also use CW 7.1 for ColdFires.
In ColdFires IDE I can cast a parameter in order it matches the expected struct, without the need of build such struct to pass it.
Example:
- THE STRUCT
struct rtc_t
{
uint8 day,month,year;
}
- THE FUNCTION
void cpu_rtc::write_rtc( rtc_t data )
{
rtc_cpu.day=data.day;
rtc_cpu.month=data.month;
rtc_cpu.year=data.year;
}
- THE CALLING
1) This works:
rtc_t r={1,2,3};// init var rtc_t type
write_rtc( r); // pass expected type to the function
2) This ( the way I want ) doesn´t work: CW complains about wrong cast.
write_rtc( (rtc_t) {26,10,9});
It works in CW7.1 for ColdFires ( pure C ...I didn´t try C++ yet)
Its very practical, once we don´t need to formally create a struct to use as parameter.
I could not make it work in CW6.2 using C++ (maybe it dodesn´t work even in C.
Did I forget some small detail to accomplish it?
Has anyone some experience like that?
Thanks everybody !!
Ricardo Raupp
That's a C99 feature called compound literals. The HC08 compiler does not support this C99 extension while the CF compiler does support it.
For now you will have to create local structs or pass the individual members separately into the function.
Daniel
Daniel
I spent a good time trying to cast it by several ways....
Can we ask Freescale to add it to CW?
Very thanks for your help..
Ricardo Raupp