參考鏈接: http://blog.csdn.net/keyeagle/article/details/6708077/
NOTICE:
靜態全局變量 與 普通的全局變量的區別
static 全局變量它只在定義它的源文件內有效,其他源文件無法訪問它, 而普通全局變量可以通過 extern 方式使用全局變量
struct: 用.name ="abc" 或 name:"abc"
#include <stdio.h> #define uint64_t int #define uint32_t int struct mtd_partition { const char *name; /* identifier string */ uint64_t size; /* partition size */ uint64_t offset; /* offset within the master MTD space */ uint32_t mask_flags; /* master MTD flags to mask out for this partition */ // struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */ }; #define MTDPART_OFS_APPEND 100 int main(int argc, char const *argv[]) { static struct mtd_partition ls1x_nand_partitions[] = { { .name = "kernel", .offset = MTDPART_OFS_APPEND, .size = 14*1024*1024, }, { .name = "rootfs", .offset = MTDPART_OFS_APPEND, .size = 100*1024*1024, }, { .name = "data", .offset = MTDPART_OFS_APPEND, .size = 100*1024*1024, }, }; static struct mtd_partition ls1x_nand_partitions1[] = { { name : "kernel", offset : MTDPART_OFS_APPEND, size : 14*1024*1024, }, { name : "rootfs", offset : MTDPART_OFS_APPEND, size : 100*1024*1024, }, { name : "data", offset : MTDPART_OFS_APPEND, size : 100*1024*1024, }, }; printf("%s\n", ls1x_nand_partitions[0].name); printf("%s\n", ls1x_nand_partitions1[0].name); return 0; }
