I tried to compile HelloWorld which produces the following error:
In file included from /home/kraus/prg/arduino-1.0.1/libraries/glcd/fonts/allFonts.h:11:0,
/home/kraus/prg/arduino-1.0.1/libraries/glcd/fonts/SystemFont5x7.h:48:28: error: variable ‘System5x7’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
In file included from /home/kraus/prg/arduino-1.0.1/libraries/glcd/fonts/allFonts.h:12:0,
Maybe related to the previos post, because i assume i have to add some "const" keywords.
Appears with Arduino 1.0 and 1.0.1, ubuntu, latest release. I have also avr-gcc on my system, i am not sure which gcc is used by Arduino IDE.
Is it sufficient to add the "const" keywords in your code?
My first and immediate concern is to get the library working for everyone on all the platforms.
After that, optimizations and enhancements can be done to make things even better.
I guess I missed from Ivan's post that this const/static/progmem stuff was creating a compile error.
I'm currently not seeing this so I need to be able to reproduce the issue.
Do you have -Werror turned on?
The IDE (at least the linux ones) does not set this option, it sets -Wall
So while it generates warnings on linux, it does not crater the compiler with an error.
What OS, IDE and gcc toolset are you using?
I'm not seeing this as an error but rather a warning - I'll have to go try it on a VM in Windoze.
I'm pretty sure I tried it on XP with 1.0 and didn't have any problem. I'll have to check it again on 1.0.1
More background and history on this below
The warning is actually a bug in the C++ compiler that the avr gcc folks have said that they are not going to fix.
It is actually a warning rather than an error.
Something about the way they handled the progmem and gcc attributes in C++ for the AVR.
I've wrestled with changing things to not have to deal with these progmem issues
for several years now. Unfortunately, there isn't a quick fix for this
and any fix has some ripple effects into other tools like FontCreator.
Some (most of it at this point) goes back to the way fonts were handled in the ks0108 library
which was the basis for the glcd v3 library.
All the fonts are currently included as a header file with the data being declared in the header.
This is ok until you have multiple source files that use the same font or include the same font header file.
If the data is not static you get multiple references
to the data structure and the link fails. If you declare them as static then the link can work but
you get multiple copies of the data included into the final image.
Also, when declared static if there is no reference to it in the module, the data is removed by the compiler.
Recent versions of the compiler and linker now have an option that will also remove dead code/data
using special sections so this helps eliminate one of the original needs for the static declaration.
With avr-g++ if you try to declare the object static const you are back where you started
and get the warning again.
The real answer is to fix how fonts are declared to avoid the need for static declarations.
It would have zero impact on the actual sketch code as it could all be under the covers.
However, it does impact all existing font header files which would suddenly become incompatible with the
library as the declaration needs to be slightly different.
It also affects FontCreator2.
While it isn't a large or complicated task to convert over to a new & better way of handling the font data,
at the time we created glcd v3 we decided not to do it.
(Michael and I did have several long conversations about doing it).
It is still on my list of things to do. Also on my list is to change the font
data format as well. I believe that Theile made a mistake in the font data format when defining
residual bits. The residual bits are encoded backwards in the byte from all the other fonts data bytes.
Another thing I'd like to look at is using bdf font format instead.
This would allow access to many fonts with a simple conversion script/tool.