C static struct

参考链接:  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;
}

 

posted @ 2017-06-14 11:12  cogitoergosum  阅读(4440)  评论(0编辑  收藏  举报