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 @   cogitoergosum  阅读(4471)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示