Related to my previous question .
I need to use a typedef from a header file ( original.h
) as a return type in another header which doesn't have access to original.h
. To complicate things further, this typedef is nested inside a class. I've tried directly copypasting the typedef, but the return types don't match in the cpp file (which does have access to original.h
).
Is there a way to either cast between identical typedefs or forward-declare a typedef (from searching up online the second one seems impossible, but maybe something could work considering it will only be used as a return type)?
Edit: full typedef:
typedef union
{
struct
{
#ifdef __vxworks
unsigned Comm : 8;
unsigned Mode : 8;
unsigned RSL : 1;
#else
unsigned RSL : 1;
unsigned Mode : 8;
unsigned Comm : 8;
#endif
};
struct
{
unsigned value : 17;
};
} tLEDs;
I ended up just manually writing a function to copy all fields of the struct, ie for this problem:
LEDs tleds_to_leds(tLEDs tleds)
{
LEDs leds;
leds.rsl = tleds.RSL;
leds.mode = tleds.Mode;
leds.comm = tleds.Comm;
leds.value = tleds.value;
return leds;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.