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;
Ich möchte b
mit Kopien von a initialisieren. Ich kann jedoch static const
Dinge mit memcpy()
nicht berühren. Und ich brauche b
zu sein static const
, weil auf diese Weise wird es in Flash und nicht RAM-Speicher gesetzt.Wie man ein Array von Strukturen statisch initialisiert?
Wie mache ich das funktioniert. Der Compiler ist arm-none-eabi-gcc
mit -std=c89
, denke ich.
Siehe die Antwort zu http://stackoverflow.com/questions/21528288/c-structure-array-initializing/ –
'.a1 = 1': unbekanntes Feld. und nicht c89. – BLUEPIXY
Überprüfen Sie das Linker-Skript für Abschnitte, die in Flash eingefügt werden, und fügen Sie ein Attribut [section] (http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes) hinzu, um es zu platzieren in diesem Abschnitt. –