Warning in Tone.cpp

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:

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

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

to this:

#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")))
#endif

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

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

Iain

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

/*88*/ // MLS: This does not make sense, the 3 options are the same
/*89*/ #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
/*90*/ 
/*91*/ #define AVAILABLE_TONE_PINS 1
/*92*/ 
/*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 */ };
/*95*/ 
/*96*/ #elif defined(__AVR_ATmega8__)
/*97*/ 
/*98*/ #define AVAILABLE_TONE_PINS 1
/*99*/

Indeed. But at least this makes it go away.

Iain

johnwasser:
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! :slight_smile:

warnings

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.