keil problem

Witam!

Mam problem z kompilatorem keil: kompiluje nastepujaca funkcje:

// funkcja konwersji czasu na wartosc unsigned lond conv(time_t *t) { unsigned long ret = t->H * 3600 + // godziny t->M * 60 + // minuty t->S; // sekundy

return (ret); }

typedef struct time_t { char t[3]; #define H t[0] #define M t[1] #define S t[3] };

i tu fragment kodu:

ctime = conv(&curent); btime = conv(&begin); etime = conv(&end);

// komparowanie czasu if (btime <= ctime && ctime > etime) { ... } else { ... }

problem polega na tym ze po uruchomieniu aplikacji okazalo sie ze funkcja nie komparuje calej wartosci chyba tzn: pomija godziny. Czy tzeba zastosowac jakies zutowanie ? gdzie moze byc blad ? Jak sie ma keil do duzych liczb ? Ile w keilu zajmuje long ?

pozdr. LB

Reply to
drozdu
Loading thread data ...

tu proponuje 3600L. albo (long)(t->H)

A tu kto wie czy (int) nie brakuje

Jak cos bedzie miedzy np 22:00 a 8:00, to bedzie klopot :-)

J.

Reply to
J.F.

dokladnie :) u mnie wyglada to tak : BOOL CompareTimes ( Time_t x, Time_t y ) { //porowanie czasow ON/OFF z aktualnym czaasem if ( x.hour > y.hour && CompareTimes ( y, x ) == FALSE ) return TRUE; //jezlie t_on > t_off to wywolaj funkcje z zamiana argumentow if ( x.hour == y.hour && x.min == y.min && x.sec == y.sec ) return TRUE; else if (( RealTime.hour > x.hour || ( RealTime.hour == x.hour && RealTime.min > x.min ) || ( RealTime.hour == x.hour && RealTime.min == x.min && RealTime.sec >= x.sec ) ) && ( RealTime.hour < y.hour || ( RealTime.hour == y.hour && RealTime.min < y.min ) || ( RealTime.hour == y.hour && RealTime.min == y.min && RealTime.sec < y.sec ) ) ) return TRUE; else return FALSE; }

typedef struct { u08 hour; u08 min; u08 sec; } Time_t;

Reply to
Pawel Kurzawa

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.