Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: [1] 2  Send TopicPrint
Very Hot Topic (More than 25 Replies) PROGMEM F() macro warning (Read 22123 times)
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
PROGMEM F() macro warning
Jan 5th, 2015 at 11:58pm
Print Post  
I've done some searching and I can find some old messages relating to this issue, but nothing in the last two years.

I'm using the F() macro extensively to store strings in PROGMEM rather than RAM. Unfortunately, these each generate a warning:
"warning: only initialized variables can be placed into program memory area"

I'm getting 98 of these in my current project which makes finding genuine errors difficult. Is there a fix or workaround?
« Last Edit: Jan 6th, 2015 at 12:00am by nevereven »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: PROGMEM F() macro warning
Reply #1 - Jan 6th, 2015 at 12:26pm
Print Post  
Hi,

You will only see the warning if you have switched on verbose or show warnings using the tools>visual micro menu.

I have seen this warning in many arduino projects. I am surprised arduino have allowed their code to produce the warning because the F() option is used so frequently and is very useful.

Actaully I was looking at another users project a few days ago and hit the same issue so I am considering having visual micro ignore the warning and not display it in the output window.

Thanks
  
Back to top
WWW  
IP Logged
 
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
Re: PROGMEM F() macro warning
Reply #2 - Jan 6th, 2015 at 2:01pm
Print Post  
I find some of the other verbose warnings useful so I wouldn't want to turn them off completely. Some way to filter these particular warnings out as a project property would probably be a better workaround.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: PROGMEM F() macro warning
Reply #3 - Jan 6th, 2015 at 2:02pm
Print Post  
Yes good idea, maybe a tools>options property that you can set for yourself

I will add it to the list.
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: PROGMEM F() macro warning
Reply #4 - Jan 11th, 2015 at 3:05am
Print Post  
please test in the latest beta 1412.10 sp4

Thanks
  
Back to top
WWW  
IP Logged
 
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
Re: PROGMEM F() macro warning
Reply #5 - Jan 11th, 2015 at 3:32am
Print Post  
Wow,

Cheesy That's great!!!!

This will make errors and real warnings so much easier to find.

Thanks!

I'm slowly learning my way around the software. The learning curve is daunting, but in 10 years of trying, this is the first IDE I've stuck with.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: PROGMEM F() macro warning
Reply #6 - Jan 11th, 2015 at 3:39am
Print Post  
Thanks for the quick feedback, good to know it works better.
  
Back to top
WWW  
IP Logged
 
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
Re: PROGMEM F() macro warning
Reply #7 - Jan 28th, 2015 at 8:30pm
Print Post  
Was this un-fixed in the latest release?

I see that 1412.10 sp4 has "Redfined F for intellisense purposes" but was this un-fixed by 1412.10 sp6 "Fix: Ensure that all compiler error messages are shown in the output window!!".

I'm still getting many "only initialized variables can be placed into program memory area" warnings from my F(). 

Is there an option I need to change?

Thanks
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: PROGMEM F() macro warning
Reply #8 - Jan 28th, 2015 at 10:22pm
Print Post  
Hi,

The fix was that the F() function had red squiggles and was reported by intellisense as being an error which was confusing.

The "only initialized variables can be placed into program memory area" is a valid and correct compiler warning that was missing along with a few other warnings in the previous release. It is correct that the use of F() causes this compiler error and correct for Visual Micro to show it. The issue is also evident in the Arduino ide if you switch on verbose compile as you have done in Visual Micro.

Does this make sense or have I missed the point?

Thanks
  
Back to top
WWW  
IP Logged
 
Serenifly
Junior Member
**
Offline


Posts: 20
Joined: Jun 20th, 2013
Re: PROGMEM F() macro warning
Reply #9 - Jan 28th, 2015 at 11:45pm
Print Post  
This is really a bug in the ancient version of the gcc compiler that comes with older Arduino versions. The warning shouldn't appear, but the bug generates it.

Download Arduino 1.5.7 or 1.5.8 and it's gone.

But note that the newer gcc version requires data in PROGMEM space to be const now. And arrays of C strings need to be const * const (const pointer to const data). There were some libraries that didn't do this (Time and UTFT for me), but current versions have that fixed.
« Last Edit: Jan 28th, 2015 at 11:48pm by Serenifly »  
Back to top
 
IP Logged
 
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
Re: PROGMEM F() macro warning
Reply #10 - Jan 29th, 2015 at 1:31am
Print Post  
Thanks, I'll try 1.5.8. Are there any downsides to the newer version?
  
Back to top
 
IP Logged
 
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
Re: PROGMEM F() macro warning
Reply #11 - Jan 29th, 2015 at 1:52am
Print Post  
I tried compiling with 1.5.8 but get this error which means nothing to me.

ibc.a(isspace.o)*:In function `isspace'
(.text.avr-libc+0x2)*:relocation truncated to fit: R_AVR_13_PCREL against symbol `__ctype_isfalse' defined in .text.avr-libc section in vr6\libc.a(cty_isfalse.o)
collect2*:error: ld returned 1 exit status
Error creating .elf
  
Back to top
 
IP Logged
 
Serenifly
Junior Member
**
Offline


Posts: 20
Joined: Jun 20th, 2013
Re: PROGMEM F() macro warning
Reply #12 - Jan 29th, 2015 at 2:53am
Print Post  
All I can tell is that it's an error from the linker, but I don't know what causes it

I didn't have any real issues with either 1.5.7 or 1.5.8. As said you may need to update some libraries that don't use const correctly when declaring PROGMEM constants, but you will notice that.

Besides finally updating the AVR toolchain, there are also lots of other improvements. For example with the Serial class. So it's worth it.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: PROGMEM F() macro warning
Reply #13 - Jan 29th, 2015 at 1:09pm
Print Post  
Serenifly is right and thanks for the useful info!

1.5.x is looking good but it does seem to break many projects. Sadly, I suspect that non-experts will stick with 1.0.x for a year or so for this reason.

It might help to know that I am looking at some sort of warning filter allowing users to ignore certainly warnings.

Thanks again Serenifly
  
Back to top
WWW  
IP Logged
 
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
Re: PROGMEM F() macro warning
Reply #14 - Jan 29th, 2015 at 3:25pm
Print Post  
A minor issue, when I switch from Arduino 1.0.x top 1.5.x and back, it forgets what kind of board I'm using.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: PROGMEM F() macro warning
Reply #15 - Jan 29th, 2015 at 3:46pm
Print Post  
Yes I know, it's only the list thanks
  
Back to top
WWW  
IP Logged
 
Serenifly
Junior Member
**
Offline


Posts: 20
Joined: Jun 20th, 2013
Re: PROGMEM F() macro warning
Reply #16 - Jan 29th, 2015 at 6:50pm
Print Post  
Someone posted a workaround on the Arduino Forum. I haven't tried that though:
http://forum.arduino.cc/index.php/topic,85840.0.html
  
Back to top
 
IP Logged
 
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
Re: PROGMEM F() macro warning
Reply #17 - Feb 8th, 2015 at 5:59pm
Print Post  
nevereven wrote on Jan 29th, 2015 at 1:52am:
I tried compiling with 1.5.8 but get this error which means nothing to me.

ibc.a(isspace.o)*:In function `isspace'
(.text.avr-libc+0x2)*:relocation truncated to fit: R_AVR_13_PCREL against symbol `__ctype_isfalse' defined in .text.avr-libc section in vr6\libc.a(cty_isfalse.o)
collect2*:error: ld returned 1 exit status
Error creating .elf


So there's a very interesting post about this on Stack Overflow.

The theory is that it has to do with the linker using rjmp and rcall rather than jmp and call. There is a 4k limit on relative jump/call and sometimes the linker exceeds this. The solution is:

Quote:
You have to let the compiler know that it needs to generate JMP/CALL instructions instead of the (more efficient) RJMP/RCALL instructions. In AVR Studio/Atmel Studio this can be done in the project's properties, toolchain, AVR/GNU C compiler, optimization. The relevant option is "Use rjmp/rcall (limited range) on >8k devices (-mshort-calls)" which needs to be unchecked to prevent the named error.
As the label indicates, the relevant command line option is -mshort-calls which needs to be removed from the gcc command line parameter list to achieve the same when invoking gcc from outside of the IDE.


Unfortunately this didn't seem to make any difference to me and I get the same error either way.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: PROGMEM F() macro warning
Reply #18 - Feb 8th, 2015 at 6:01pm
Print Post  
if you are using visual micro to compile then you need to change the arduino ide hardware\avr\platform.txt or sam\platform.txt. The atmel project properties are currently unused for arduino
  
Back to top
WWW  
IP Logged
 
nevereven
Junior Member
**
Offline


Posts: 59
Joined: Dec 5th, 2014
Re: PROGMEM F() macro warning
Reply #19 - Feb 8th, 2015 at 9:26pm
Print Post  
Thanks. I looked in platform.txt and boards.txt and didn't see any reference to -mshort-calls to remove, so I'm stuck again. Perhaps this isn't the problem.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint