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;
我想初始化b
的副本。但是,我不能觸及static const
東西memcpy()
。我需要b
爲static const
,因爲這樣它就會被放入閃存而不是內存。如何靜態地初始化一個結構數組?
我該如何做這項工作。編譯器是arm-none-eabi-gcc
與-std=c89
,我想。
請參閱http://stackoverflow.com/questions/21528288/c-structure-array-initializing/ –
'.a1 = 1'的答案:未知字段。而不是c89。 – BLUEPIXY
檢查鏈接描述文件以獲取放入Flash的部分,並添加一個'section' [屬性](http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes)來放置它在那一節。 –