Search code examples
ceclipseautocompletetypedefunions

typedef union in C and eclipse autocomplete


I'm trying to declare a typedef union for a time format as follows, In the header I have :

typedef union _u_time
{
    unsigned long l_time;
    struct {
        unsigned char :8;
        unsigned char HRS;
        unsigned char MIN;
        unsigned char SEC;
    }BYTES;
}u_time;

And then I'm trying to use it this way :

void RTC_Set(long date, u_time time)
{
    RTC_SetTime(time);
    RTC_SetDate(date);
}

No problem to compile the project. I'm using E2Studio IDE from Renesas based on Eclipse and the problem is that u_time is not resolved in my *.c file and I can't use autocompletion which is a great advantage of Eclipse...

The only way I found to get all links resolved and autocompletion working is to add union in de function prototype like this :

void RTC_Set(long date, union u_time time)
{
    RTC_SetTime(time);
    RTC_SetDate(date);
}

Any idea ?


Solution

  • I solved my problem ! I had to use an Eclipse functionality which I didn't know !

    Left click on the Project in the project Explorer Index -> Rebuild

    Now autocomplete is ok, and no error remain about this problem.