I am compiling the sketch found here. I just downloaded the .ino and .h files and opened them, so I have not modded the code at all. I keep getting the following error.
In file included from flappyDuino.ino:7:0:
Sprite.h:3: error: variable 'flappybird_frame_1' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static unsigned char PROGMEM flappybird_frame_1[] = { 0x03, 0xF0, 0x0C, 0x48, 0x10, 0x84, 0x78, 0x8A, 0x84, 0x8A, 0x82, 0x42, 0x82, 0x3E, 0x44, 0x41,0x38, 0xBE, 0x20, 0x41, 0x18, 0x3E, 0x07, 0xC0 };
^
In file included from flappyDuino.ino:7:0:
Sprite.h:4: error: variable 'flappybird_frame_2' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static unsigned char PROGMEM flappybird_frame_2[] = { 0x03, 0xF0, 0x0C, 0x48, 0x10, 0x84, 0x20, 0x8A, 0x40, 0x8A, 0x40, 0x42, 0x7C, 0x3E, 0x82, 0x41, 0x84, 0xBE, 0x88, 0x41, 0x78, 0x3E, 0x07, 0xC0 };
^
Sprite.h:5: error: variable 'bar_bottom' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static unsigned char PROGMEM bar_bottom[] = { 0xFF, 0xFF, 0xFF, 0x42, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E };
^
Sprite.h:6: error: variable 'bar_top' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
static unsigned char PROGMEM bar_top[] = { 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x42, 0xFF, 0xFF, 0xFF };
^
variable 'flappybird_frame_1' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
I'd appreciate any help.
1 Answer 1
The arrays need to be tagged with the keyword const
. It is possible that the original sketch was written using an earlier version of the IDE that you are using (or a later version?) and your version requires the const
keyword whereas the author's doesn't.
Basically any arrays that are PROGMEM
need the word const
adding to them. For instance, lines that start:
static unsigned char PROGMEM ...
need changing to:
static const unsigned char PROGMEM ...
-
Thank you for answering why the sketch would not contain the necessary const. BTW Does the ! symbol mean not throughout the Arduino IDE, so that the statement "if (!player.isDead()) means if isDead is not true then. . .Gabe Ruiz– Gabe Ruiz2015年10月01日 18:51:46 +00:00Commented Oct 1, 2015 at 18:51
-
Yes,
!
is logical negation - true becomes false, false becomes true. So !player.isDead() would logically be the same as (if the function existed) player.isAlive().Majenko– Majenko2015年10月01日 18:53:34 +00:00Commented Oct 1, 2015 at 18:53
const
.const
after the wordstatic
.