如何在 C 中创建静态易失性结构数组?

How do I create an array of static volatile structs in C?

正如标题所说,我接手的一个项目有一个静态的 volatile 结构,它基本上保存连接到 WiFi 网络时的网络数据。我需要创建这些结构的数组来保存以前网络的数据。

这就是我要复制的结构的样子:

static volatile struct
{
    BYTE        MySSID[32]; 
    BYTE        SsidLength;             
    BYTE        SecurityMode;           
    BYTE        SecurityKey[32];           
    BYTE        SecurityKeyLength;
    BYTE        dataValid;
    BYTE        networkType;
    BYTE        IsLinked;
    BYTE        ConnectionID;
} NetworkStruct;

这是我最近一次失败的创建数组的尝试,我可以将此结构中的数据复制到:

static volatile struct
{
    BYTE        MySSID[32]; 
    BYTE        SsidLength;             
    BYTE        SecurityMode;           
    BYTE        SecurityKey[32];           
    BYTE        SecurityKeyLength;
    BYTE        dataValid;
    BYTE        networkType;
    BYTE        IsLinked;
    BYTE        ConnectionID;
} SavedNetworks[10];

到目前为止,这次和其他所有尝试都会引发错误。

这是上述尝试抛出的错误:

Link Error: Could not allocate section .nbss, size = 944 bytes, attributes = bss near
Link Error: Could not allocate data memory

Link Error: Could not allocate section .nbss, size = 944 bytes

链接器无法为 .bss 部分中的数组分配所需的内存,这是所有未初始化的静态存储持续时间变量所在的位置。您为 statics/globals 使用了太多内存,就这么简单。

如何解决取决于具体的系统