2018年12月18日 星期二

Keil C: Warning: #1296-D: extended constant initialiser used"?


The root cause is miss use a pointer to a static variable like:

int x = 1;
int y = (int) &x;

Modify version

int x = 1;
int *y = &x;

printf("%p\n", &x);  // memory address of x
printf("%p\n", &y);   // memory address of y

printf("%p\n", y);     // y = memory address of x
printf("%d\n", *y);   // *y = memory content of x  = 1


Addresses are not arithmetic types in ANSI C spec, so if need to get the address of a static variable, use a pointer point to the variable's address.







Ref :
 1. http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15182.html
 2.https://openhome.cc/Gossip/CGossip/Pointer.html

Linux driver: How to enable dynamic debug at booting time for built-in driver.

 Dynamic debug is useful for debug driver, and can be enable by: 1. Mount debug fs #>mount -t debugfs none /sys/kernel/debug 2. Enable dy...