Hello. I am developing using de FRDMKE02 and using the CW Sevelopment Studio. In my project, I have defined the following structure for dealing with time:
typedef struct TimeStruct {
unsigned char SECONDS;
unsigned char MINUTES;
unsigned char HOURS;
unsigned char DAY_OF_THE_WEEK;
unsigned char DATE;
unsigned char MONTH;
unsigned char YEAR;
};
I have done a fuction in which I want to add a determined quantity of time (days, hours and minutes; defined by char add_dd, char add_hh and char add_mm respectively) to the entrant TimeStruct and then it should return the resulting TimeStruct. The problem is that I can't even build this fuction.
The error log says that: "return type is an incomplete type".
I hope someone can help me. Regards, Juan Ignacio Troisi
The intended function is:
struct TimeStuct sumar_horas_y_minutos(struct TimeStruct TIEMPO_SUMADO,char add_dd,char add_hh,char add_mm){
TIEMPO_SUMADO.MINUTES = TIEMPO_SUMADO.MINUTES + add_mm;
if(TIEMPO_SUMADO.MINUTES > 59){
TIEMPO_SUMADO.HOURS ++;
TIEMPO_SUMADO.MINUTES = TIEMPO_SUMADO.MINUTES - 60;
}
TIEMPO_SUMADO.HOURS = TIEMPO_SUMADO.HOURS + add_hh;
if(TIEMPO_SUMADO.HOURS >= 24){
TIEMPO_SUMADO.DATE ++;
TIEMPO_SUMADO.HOURS = TIEMPO_SUMADO.HOURS - 24;
}
TIEMPO_SUMADO.DATE = TIEMPO_SUMADO.DATE + add_dd;
switch_month(TIEMPO_SUMADO);
if(TIEMPO_SUMADO.MONTH > 12){
TIEMPO_SUMADO.YEAR ++;
TIEMPO_SUMADO.MONTH = TIEMPO_SUMADO.MONTH -12;
}
return TIEMPO_SUMADO;
}
Hello Juan Ignacio Troisi:
There is a typo in your code:
That should be TimeStruct. Also for the typedef you should declare an identifier name.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you but, unfortunately, I can't build build the project yet.
When I don't call the function, it builds. However, when I want to use it (it calling doing: 'sumar_horas_y_minutos(TIEMPO_SUMADO,add_dd,add_hh,add_mm);', the following error turns up:
"conflicting types for sumar_horas_y_minutos".
the code is:
struct TimeStruct sumar_horas_y_minutos(struct TimeStruct TIEMPO_SUMADO,char add_dd,char add_hh,char add_mm){
TIEMPO_SUMADO.MINUTES = TIEMPO_SUMADO.MINUTES + add_mm;
if(TIEMPO_SUMADO.MINUTES > 59){
TIEMPO_SUMADO.HOURS ++;
TIEMPO_SUMADO.MINUTES = TIEMPO_SUMADO.MINUTES - 60;
}
TIEMPO_SUMADO.HOURS = TIEMPO_SUMADO.HOURS + add_hh;
if(TIEMPO_SUMADO.HOURS >= 24){
TIEMPO_SUMADO.DATE ++;
TIEMPO_SUMADO.HOURS = TIEMPO_SUMADO.HOURS - 24;
}
TIEMPO_SUMADO.DATE = TIEMPO_SUMADO.DATE + add_dd;
switch_month(TIEMPO_SUMADO);
if(TIEMPO_SUMADO.MONTH > 12){
TIEMPO_SUMADO.YEAR ++;
TIEMPO_SUMADO.MONTH = TIEMPO_SUMADO.MONTH -12;
}
return TIEMPO_SUMADO;
}
Thanks