[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>【C语言】代码命名规范
#ifndef _MSG_H_ #define _MSG_H_ typedef struct msg_s { uint8_t msgType; uint8_t
msgId; uint8_t msgLen; void (*fpSendMsg) (uint8_t *data); } msg_t,*msg_pt;
msg_t g_msg;//全局变量 void gSendMsg(uint8_t *data);//全局函数 #endif #include "msg.h"
static msg_t _msg;//文件内静态变量 static void _SendMsg(uint8_t *data){//文件内静态函数 static
int f_msg;//函数内静态变量 }
C命名规范有很多,这里统一下自己的使用习惯,以以上代码为例,说明命名规则:
<>一、变量的命名
<>1.以驼峰式命名作为基础
* 驼峰式命名:混合使用大小写字母来构成标识符的名字,其中第一个单词首字母小写,余下的单词首字母大写,且尽量使用缩写,如:msgType;
* 驼峰式命名补充:若只有一个关键词,使用小写,如:msg。
<>2.下划线辅助定义
下划线只在描述变量属性的时候使用
* 描述类型:使用后缀
* _s表示这是一个结构体(struct);struct msg_s{ };
* _t表示这是一个结构体类型(typedef);typedef struct msg_s{ } msg_t;
* _pt表示这是一个架构体指针。typedef struct msg_s{ } *msg_pt;
* 描述作用域:使用前缀
* g_表示这是一个全局变量(global);msg_t g_msg;
* _或者n表示这是一个文件内静态变量(native);static msg_t _msg;
* f_表示这是一个函数内静态变量。{static int f_msg;}
<>二、函数的命名
<>1.以帕斯卡命名为基础
帕斯卡(Pascal)命名法和骆驼命名法相似,但帕斯卡命名法则是第一个单词首字母大写。与函数命名相关的(包括函数指针)使用帕斯卡是为了与变量区分。如:
void SendMsg (uint8_t *data);
<>2.前缀辅助定义
因为函数的首字母已经大写,可以直接使用小写的前缀,不需要借助下划线也不至于混淆
* 描述类型:使用前缀
* fp表示这是一个函数指针。 void (*fpSendMsg) (uint8_t *data);
* 描述作用域:使用前缀
* g表示这是一个全局函数;void gSendMsg(uint8_t *data);
* _或者n表示是一个文件内静态函数。static void _SendMsg(uint8_t *data);
<>三、宏定义
全部大写