In C, when I want to put number 5 at address 0x28, I can do it this way:
char* x = (char *) 0x28;
*x = 5;
If I want, I can do the same without declaring a variable:
*((char *) 0x28) = 5;
If I want that compiler treats this address as volatile, I can do it this way:
volatile char* x = (char *) 0x28;
*x = 5;
Can I do it without declaring a variable?
Edit: Let me explain why I want to do "*((char *) 0x28) = 5". I write a blinking LED hello world program for ATmega32U4 and I know that address 0x28 rules the pin to which my LED is connected. And it does work: the C code which you suggested compiles to correct machine code and the LED blinks.
这很简单:
*((volatile char *) 0x28) = 5;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.