大鼻子JOJO 2023-03-25 23:53 采纳率: 70.6%
浏览 94
已结题

expected declaration specifiers or '...' before numeric报错

expected declaration specifiers or '...' before numeric constant malloc.c C/C++ Problem

代码是这样写的

__align(32) u8 mem1base[MEM1_MAX_SIZE];                                                    //内部SRAM内存池
__align(32) u8 mem2base[MEM2_MAX_SIZE] __attribute__((at(0X68000000)));                    //外部SRAM内存池

//内存管理表
u16 mem1mapbase[MEM1_ALLOC_TABLE_SIZE];                                                    //内部SRAM内存池MAP
u16 mem2mapbase[MEM2_ALLOC_TABLE_SIZE] __attribute__((at(0X68000000+MEM2_MAX_SIZE)));    //外部SRAM内存池MAP

下面还有一句调用mem1base和mem2base的语句

//内存管理控制器
struct _m_mallco_dev mallco_dev=
{
    my_mem_init,                //内存初始化
    my_mem_perused,                //内存使用率
    mem1base,mem2base,            //内存池
    mem1mapbase,mem2mapbase,    //内存管理状态表
    0,0,                           //内存管理未就绪
};

编译结果报错:

'mem1base' undeclared here (not in a function); did you mean 'mem1mapbase'?
'mem2base' undeclared here (not in a function); did you mean 'mem2mapbase'?

expected declaration specifiers or '...' before numeric constant
expected declaration specifiers or '...' before numeric constant

请问是什么原因导致了这样呢?

  • 写回答

3条回答 默认 最新

  • threenewbee 2023-03-25 23:56
    关注

    看看是不是函数声明没有写或者一些符号,特别是上一行的分号遗漏

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 4月8日
  • 已采纳回答 3月31日
  • 创建了问题 3月25日