Embedded C Note

1. gcc: gcc -o build xxx.c.  --> 

2. Macro #define ABC (5+3)

               #defien ABC(x) (5+(x))

               #define MIN(A,B) ((A) <= (B) ? (A) : (B))

3. Singed: MSB is sign bit. 1 is negative

4. "goto" can only jump in the function. Cannot jump bettwen functions

5. Storage class(specify the location of variables):

  1. auto(default) R/W, if the auto variable is in the {}, then its stored in SLACK
  2. register, stored in register. cannot use & to get the address
  3. static, Static variables are allocated memory in data segment, not stack segment and can also won't be used by other file if there functions have the same name. 
  4. const, cannot edit directly, but can be changed by using pointer
  5. extern,
  6. volatile, won't be optimize by the compiler. 

6. Operator :

  1. Logic Operator A && B, won't caculate B if A is 0. so A && B != B && A
  2. When >>, nagative value fill the MSB with "1" instead of zero. 
  3. reset bit 5: result =  a & (~(0x1 << 5)); to make sure MSB-->BIT 5 is 0.

7. Pointer:

const char *p/char const *p: the content cannot be changed

char * const p/char *p const: address cannot be changed

8. Storage of embedded C

C Storage Classes | Four Most Useful Types of Storage Classes in C 

Memory Layout of Embedded C Programs - Open4Tech

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值