C: @ Operator?

Apr 4, 2011 at 2:03pm
What does @ operator do?
Or does such an operator even exist in standard C/C++?

While programming Microchip Controllers in C, a popular compiler uses @ operator to define variables at a given address inside the memory. For example
volatile unsigned char ABC @ 0x0A
declares an 8-variable called ABC at the address 0x0A in the data memory of uC.

Is it a standard procedure? While programming inside an operating system, is it possible to use @ to define and therefore access a specific memory location?
Apr 4, 2011 at 3:52pm
No, the C++ grammar does not include an operator @.
Apr 4, 2011 at 4:57pm
It's neither part of the C nor the C++ language. May be some compiler allows this, but it's definitely not part of the standard.
Apr 5, 2011 at 2:51pm
Thanks. I was just wondering, if that was a standard C++ operator, that'd render the memory management modules of the operating system purposeless, every program for itself. But clearly, that is not the case...

Most probably, that is a facility only in uC programming because 1) it has a smaller memory and to access those memory locations, you have to take extreme care, 2) the control registers and data memory share the same memory chunk. So that may be why Hi-Tech C Compiler allows that operator.
Apr 5, 2011 at 8:07pm
BTW, C++ has "placement new" which does the same thing. volatile unsigned char* ABC = new (0xa) unsigned char; would create a variable ABC which points to memory location 0xa.
Topic archived. No new replies allowed.