【发布时间】:2014-02-05 11:29:49
【问题描述】:
struct A{
int a; int b;
};
static const struct A a = {.a1 = 1, .a2 = 42};
struct B{
struct A[666][510]
};
static const struct B b;
我想用 a 的副本初始化 b。但是,我不能用memcpy() 触摸static const 的东西。我需要b 成为static const,因为这样它会被放入闪存而不是内存中。
我该如何进行这项工作。我想编译器是arm-none-eabi-gcc 和-std=c89。
【问题讨论】:
-
.a1 = 1:未知字段。而不是 c89。 -
检查链接描述文件中放入闪存的部分,并添加
sectionattribute 将其放入该部分。 -
所以你想要同一对数据的 666*510 个副本?你希望它是常量吗?我只是好奇这会有什么用。
-
@BLUEPIXY,这是 ansi c 和 gnu 扩展的一些奇怪组合。例如
for(int i = 0;i < 5; i++)不会编译。