Pages: [1]   Go Down
Author Topic: Warning in Tone.cpp  (Read 2990 times)
0 Members and 1 Guest are viewing this topic.
Guildford, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 217
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
#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
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
/*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*/
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Guildford, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 217
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Indeed. But at least this makes it go away.

Iain
Logged

Dallas, TX USA
Offline Offline
Edison Member
*
Karma: 48
Posts: 2351
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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! smiley
Logged

Offline Offline
Sr. Member
****
Karma: 3
Posts: 327
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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,


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: