打印:
#define DBG_vPrintf(a,b,ARGS...) do { if (a) printf(b, ## ARGS); } while(0)
#define DBG_vAssert(a,b) do { if (a && !(b)) printf(__FILE__ " %d : Asset Failed\n", __LINE__ ); } while(0)
#define UI_BLUE(x) "\e[34;1m"x"\e[0m"
#define UI_GREEN(x) "\e[32;1m"x"\e[0m"
#define UI_YELLOW(x) "\e[33;40;1m"x"\e[0m"
#define UI_RED(x) "\e[31;1m"x"\e[0m"
#define DBG_ERR if (defined_dbg & DBG_ERROR) \
printf(UI_RED("[WIFI-ERR]")" %s,%s,%d\n",__FILE__,__FUNCTION__,__LINE__); \
printf
#define DBG_INFO if (defined_dbg & DBG_INFOR) \
printf(UI_BLUE("[WIFI-INFO]")" %s,%s,%d\n",__FILE__,__FUNCTION__,__LINE__); \
printf
#define DBG_DBG if (defined_dbg & DBG_DUBGER) \
printf(UI_GREEN("[WIFI-DBG]")" %s,%s,%d\n",__FILE__,__FUNCTION__,__LINE__); \
printf
#define DBG_WAN if (defined_dbg & DBG_WANNING) \
printf(UI_YELLOW("[WIFI-DBG]")" %s,%s,%d\n",__FILE__,__FUNCTION__,__LINE__); \
printf
6.标号元素
标准 C 要求数组或结构体的初始化值必须以固定的顺序出现,在 GNU C 中,通
过指定索引或结构体成员名,允许初始化值以任意顺序出现。
指定数组索引的方法是在初始化值前添加“ [INDEX] =” ,当然也可以用
“[FIRST … LAST] =”的形式指定一个范围。例如下面的代码定义一个数组,并把其
中的所有元素赋值为 0:
unsigned char data[MAX] = { [0 ... MAX-1] = 0 };
下面的代码借助结构体成员名初始化结构体:
struct file_operations ext2_file_operations =
{
llseek: generic_file_llseek,
read: generic_file_read,
write: generic_file_write,
ioctl: ext2_ioctl,
mmap: generic_file_mmap,
open: generic_file_open,
release: ext2_release_file,
fsync: ext2_sync_file,
};
但是,Linux 2.6 推荐类似的代码应该尽量采用标准 C 的方式,如下所示:
struct file_operations ext2_file_operations =
{
.llseek = generic_file_llseek,
.read = generic_file_read,
.write = generic_file_write,
.aio_read = generic_file_aio_read,
.aio_write = generic_file_aio_write,
.ioctl = ext2_ioctl,
.mmap = generic_file_mmap,
.open = generic_file_open,
.release = ext2_release_file,
.fsync = ext2_sync_file,
.readv = generic_file_readv,
.writev = generic_file_writev,
.sendfile = generic_file_sendfile,
};
时间: 2024-10-28 20:18:51