This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Thu, 2004-04-29 at 02:22, Bill Gatliff wrote: > Grant: > > > >test_struct.test_short = 0x1234; > >printf("%04x\n", test_struct.test_short); > > > >_may_ work. I don't think it's guaranteed to work, though. > > > > Actually, I'm pretty sure it is guaranteed to work as long as the > compiler can see the "packed" attribute during compilation (if it > couldn't, that would be a serious structural problem in your source code!). > > >> test_pointer = &test_var.test_short; > >> > >> > > > >test_pointer now points to an odd address. Dereferencing it > >will almost certainly not work right, since the compiler > >doesn't generate run-time checks for misaligned pointers. > > Wrong. You can't take the address of a packed element and store it in a normal pointer. Normal pointers can't handle unaligned objects. You'd need to create a structure containing only a packed short and then play games using that. It's sometimes a real shame that gcc doesn't have short attribute((packed)) *f; but it doesn't, so the test case is not valid GNU C. R. ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |