On Thursday 10 November 2005 05:26, Tom Walsh wrote: > szemzoandras wrote: > >Hello, > > > > > >Is it possible to place a variable to a fixed memory location in gcc, > >like in keil, i mean: > > > >unsigned int dd _at_ 0x81000000; > > FWIW, I wonder why Keil added an extension to their C compiler? I've > been using "int * dd = ((unsigned int *)0x81000000)" for many many > years. Not only with gcc, but other compilers as well. There is a difference. When you do something like: unsigned int dd _at_ 0x810000; often the linker will check for overlaps etc. Depends on the compiler/linker though. Also, you need to look at the their offerings to understand it. Their older compilers (8051 etc) had this feature and so did PLM (now that was a fantastic language for 8051s)! They don't want to make their newer compilers seem less capable. When you do int * dd = ((unsigned int *)0x81000000 you're bypassing everything. That's probably fine for accessing hard locations like peripherals etc. IMHO, using extensions is a very bad thing. It was OK in the days of 8-bitters where "C" code was just a C representation of assembly and code was very non-portable. With most code though, you need portability. Heck I still use code I first wrote 15 years ago and have been dragging from project to project. Using any non-standard things breaks portability. I prefer to not do any of this sort of thing (except for hardware-specified stuff like peripherals) and instead use linker scripts to do any placement.
Message
Re: [lpc2000] fixed address variable
2005-11-09 by Charles Manning
Attachments
- No local attachments were found for this message.