david-furminieux / er9x

Automatically exported from code.google.com/p/er9x
0 stars 1 forks source link

Various "must be const" errors when compiling with avr-gcc 4.6.1 #319

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
[fabio@gamma src]$ make

-------- begin --------
avr-gcc (GCC) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Generate Version-stamp:
//Automatically generated file - do not edit
#define DATE_STR "10.09.2011"
#define TIME_STR "12:12:40"
#define SUB_VERS 4789-fabio
#define SVN_VERS "trunk-r531"
#define MOD_VERS "   "

Compiling C++: er9x.cpp
avr-gcc -c -mmcu=atmega64 -I. -x c++ -gdwarf-2 -DF_CPU=16000000UL -Os -Wall  
-MD -MP -MF .dep/er9x.o.d er9x.cpp -o obj/er9x.o
In file included from er9x.cpp:17:0:
er9x.h:167:33: error: variable 'modn12x3' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.h:178:33: error: variable 'chout_ar' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
In file included from er9x.cpp:17:0:
er9x.h:254:31: error: variable 's_charTab' must be const in order to be put 
into read-only section by means of '__attribute__((progmem))'
er9x.h:668:36: error: variable 'modi12x3' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
In file included from er9x.cpp:18:0:
s9xsplash.lbm:1:26: error: variable 's9xsplash' must be const in order to be 
put into read-only section by means of '__attribute__((progmem))'
er9x.cpp:42:30: error: variable 'modi12x3' must be const in order to be put 
into read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void putsChnRaw(uint8_t, uint8_t, uint8_t, uint8_t)':
er9x.cpp:84:22: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp:88:22: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void putsChn(uint8_t, uint8_t, uint8_t, uint8_t)':
er9x.cpp:93:20: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void putsDrSwitches(uint8_t, uint8_t, int8_t, uint8_t)':
er9x.cpp:100:44: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp:101:44: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp:102:44: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'const prog_char* get_switches_string()':
er9x.cpp:110:10: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void putsTmrMode(uint8_t, uint8_t, uint8_t)':
er9x.cpp:117:26: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void checkMem()':
er9x.cpp:400:11: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void alertMessages(const prog_char*, const prog_char*)':
er9x.cpp:408:28: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp:411:23: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void checkTHR()':
er9x.cpp:434:18: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp:434:45: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void checkAlarm()':
er9x.cpp:456:36: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void checkWarnings()':
er9x.cpp:463:15: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void checkSwitches()':
er9x.cpp:473:18: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp:473:44: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void checkQuickSelect()':
er9x.cpp:517:34: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void message(const prog_char*)':
er9x.cpp:543:28: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void alert(const prog_char*, bool)':
er9x.cpp:554:30: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp:556:29: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void popMenu(bool)':
er9x.cpp:771:11: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void pushMenu(MenuFuncP)':
er9x.cpp:788:11: error: variable '__c' must be const in order to be put into 
read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'void perMain()':
er9x.cpp:917:41: error: variable 'beepTab' must be const in order to be put 
into read-only section by means of '__attribute__((progmem))'
er9x.cpp: In function 'uint16_t anaIn(uint8_t)':
er9x.cpp:1040:33: error: variable 'crossAna' must be const in order to be put 
into read-only section by means of '__attribute__((progmem))'
make: *** [obj/er9x.o] Error 1

Original issue reported on code.google.com by fabio.va...@gmail.com on 10 Sep 2011 at 10:22

GoogleCodeExporter commented 9 years ago
Sorry, that's a bug in the compiler not this software. 
http://arduino.cc/forum/index.php?action=printpage;topic=66710.0

Original comment by fabio.va...@gmail.com on 10 Sep 2011 at 11:50

GoogleCodeExporter commented 9 years ago
Main issue was caused by the compiler, but version 4.6.2 should be working and 
there are still problems with the code. Together with new avr-libc, problem is 
even bigger.

Now you get:
lcd.h:73:63: error: 'prog_char' does not name a type
gruvin9x.h:275:14: error: 'prog_uint8_t' does not name a type
and other alike. There is a change in pgmspace.h:
==============
   This typedef is now deprecated because the usage of the __progmem__ 
   attribute on a type is not supported in GCC. However, the use of the 
   __progmem__ attribute on a variable declaration is supported, and this is 
   now the recommended usage.

   The typedef is only visible if the macro __PROG_TYPES_COMPAT__
   has been defined before including <avr/pgmspace.h> (either by a
   #define directive, or by a -D compiler option.)
==============
using that #define changes errors to warnings "prog_char is deprecated".

It still does not help, because PSTR definition is not compatible with new gcc 
(4.6.2, containing The Fix). It was fixed in avr-libc, but your copy of that 
definition needs the fix:
-#define PSTR(s) (__extension__({static prog_char APM __c[] = (s);&__c[0];}))
+#define PSTR(s) (__extension__({static const prog_char APM __c[] = 
(s);&__c[0];}))

Also I had to remove --combine option. From gcc upstream (4.6 changes):
unrecognized option '-combine':
    The -combine option has been removed, it has been very buggy and has
    been superceeded by -flto.  Either drop it, or build with -flto.

Anyway, to compile this, I had to add const on several places. This is with gcc 
4.6.2, so with original issue fixed. It's not going to be better without 
changes in the code.

Original comment by mih...@mihlit.cz on 16 Jan 2012 at 1:40

GoogleCodeExporter commented 9 years ago
> lcd.h:73:63: error: 'prog_char' does not name a type
> gruvin9x.h:275:14: error: 'prog_uint8_t' does not name a type

these are from gruvin9x, but everything I wrote is valid for er9x

Original comment by mih...@mihlit.cz on 17 Jan 2012 at 10:17