From: Kajetan N. <Kaj...@gm...> - 2011-08-01 13:17:34
|
OK. But it doesn’t solve the whole Problem. In the application we read the bytes from the serial port and store them into a buffer (char array). The data structure doesn’t exist just of double numbers but has also chars float and so on. So the address mod 8 of the double values are not always = 0. Has anybody a different solution to this problem? Instead of copy the stream. Kajetan > I expect you have an alignment problem. > > buffer[2] is not properly aligned to a dword boundary, address mod 8 != 0 > > RP > > On 7/28/11, "Kajetan Nürnberger" <Kaj...@gm...> wrote: > > Hello Guys, > > > > i have a problem to cast a double number out of a array of chars. > > > > Te following code works on an ubuntu Linux system but doesn't work with > the > > gumstix system. > > > > int main() { > > cout <<"Hallo"<< endl; // prints > > > > char buffer[500]; > > for(int i = 0; i <500; i++) > > { > > buffer[i] = 0x0B; > > } > > > > double test; > > > > test = *(double*) &buffer[2]; > > > > cout<<"Test: "<<test<<endl; > > > > > > > > > > return 0; > > } > > > > > > To make the code work, I have to copy the 8 bytes of the buffer to an > extra > > array with 8 elements before casting it to double. > > > > Can somebody tell me why the code shown above doesn't work on gumstix? > > > > Thank you very much. > > > > -- > > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir > > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de > > > > > ------------------------------------------------------------------------------ > > Got Input? Slashdot Needs You. > > Take our quick survey online. Come on, we don't ask for help often. > > Plus, you'll get a chance to win $100 to spend on ThinkGeek. > > http://p.sf.net/sfu/slashdot-survey > > _______________________________________________ > > gumstix-users mailing list > > gum...@li... > > https://lists.sourceforge.net/lists/listinfo/gumstix-users > > > > ------------------------------------------------------------------------------ > Got Input? Slashdot Needs You. > Take our quick survey online. Come on, we don't ask for help often. > Plus, you'll get a chance to win $100 to spend on ThinkGeek. > http://p.sf.net/sfu/slashdot-survey > _______________________________________________ > gumstix-users mailing list > gum...@li... > https://lists.sourceforge.net/lists/listinfo/gumstix-users -- NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone |