0

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.

4
  • What it says... make those variables const.
    – Majenko
    Commented Sep 30, 2015 at 22:05
  • This is embarrassing. . . But how?
    – Gabe Ruiz
    Commented Sep 30, 2015 at 22:06
  • By adding the word const after the word static.
    – Majenko
    Commented Sep 30, 2015 at 22:08
  • Thank you. I had const on the back of my head but wasn't sure where to put it.
    – Gabe Ruiz
    Commented Sep 30, 2015 at 22:11

1 Answer 1

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 ...
2
  • 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
    Commented 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
    Commented Oct 1, 2015 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.