C kerdes
vajk fekete
halaloszto at yahoo.co.uk
Wed Mar 21 23:11:29 CET 2007
ha az uint es az uchar merete nem azonos akkor van pityputty.
A castolas az tipuskenyszerites, nem csinal semmit, csak a forditoval elhiteti hogy az a tipus.
ha egy byte-ot atcastolok egy word-re, egyszeruen hozzavesz megegy(par) byteot mellole a memoriabol.
ha implicit tipuskonverzio tortenik, akkor futasidoben mindent rendesen megcsinal. a 01 konvertalva szelesebbre 00000001 lesz.
vajk
Fuzesi Arnold <arnold.fuzesi.lista at gmail.com> wrote: full optimalizacio, eredmenye:
#define EE_CHECKSUM(srcstruct) ee_checksum( ((uchar __eeprom*) &srcstruct),
sizeof(srcstruct)-1)
/******************************************************************************/
uint ee_checksum(uchar __eeprom* data, uint length)
{
uint checksum = 0;
do{
checksum+=(*data++);
}
while(--length);
return checksum;
}
/******************************************************************************/
typedef struct{
blabla
uchar ee_checksum
} FW;
volatile __eeprom FW ee_fw;
ez nem mukodik:
if(ee_fw.checksum!=EE_CHECKSUM(ee_fw)){
blabla
}
ez mukodik:
if(ee_fw.checksum!=(uchar)EE_CHECKSUM(ee_fw)){
blabla
}
Ezt most hirtelen nem ertem....vki erti?
Most vagy az ee_fw.checksum-ot kellene castolnia magatol uint-re, vagy az
ee_checksumot castolni uchar-ra..
A.
-----------------------------------------
elektro[-flame|-etc]
---------------------------------
What kind of emailer are you? Find out today - get a free analysis of your email personality. Take the quiz at the Yahoo! Mail Championship.
More information about the Elektro
mailing list