Go Down

Topic: Warning in Tone.cpp (Read 6103 times) previous topic - next topic


In Arduino v1.0 all warnings are turned on by default. Tone.cpp generates a warning:

arduino-1.0\hardware\arduino\cores\arduino\Tone.cpp:93: warning: only initialized variables can be placed into program memory area

This can be fixed by changing Tone.cpp

from this:

Code: [Select]

#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "Arduino.h"
#include "pins_arduino.h"

#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)

to this:

Code: [Select]

#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "Arduino.h"
#include "pins_arduino.h"

// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
#ifdef PROGMEM
#undef PROGMEM
#define PROGMEM __attribute__((section(".progmem.data")))

#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)

Hope that helps anyone else who is also frustrated when red text rushes by in the IDE.



Odd that the message shows up.  The variable being put into PROGMEM is initialized:

Code: [Select]

/*88*/ // MLS: This does not make sense, the 3 options are the same
/*89*/ #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
/*91*/ #define AVAILABLE_TONE_PINS 1
/*93*/ const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
/*94*/ static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
/*96*/ #elif defined(__AVR_ATmega8__)
/*98*/ #define AVAILABLE_TONE_PINS 1
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


Indeed. But at least this makes it go away.



Odd that the message shows up.  The variable being put into PROGMEM is initialized:

It depends on what "initialized" means. If it means initialized data, i.e. data that is copied from
flash to RAM during startup to "initialize" the variable, then no, it is not an initialized data variable.

My question, is if you do this, does it break the linker optimization, -fdata-sections so that
unused progem data will now end up in flash.
It should be easy to run a test to see.

--- bill


Is this solution still supposed to work for ide 1.0.5? I tried it but still get the warnings... :S
I'm implementing a webserver, using F() and PSRT() everywere... Feels like watching a horror gory movie with all the red coming from everywere! :)



dont hold your breath on getting any warnings fixed in arduino,

Ive been working with arduino a year or two, and the same warnings have been there, and fix's highlighted, again and again,

I tell my class that warnigns are important to take notice off,
   and you should get rid of them,


yeah,think so,Indeed. But at least this makes it go away.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131