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;
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM