bugSimulavr: an AVR simulator - Bugs: bug #35737, new awr-gcc is picky about...


bug #35737: new awr-gcc is picky about depreciated constants

Submitted by:  None
Submitted on:  Tue Mar 6 22:38:47 2012  
Category: ConfigureSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Originator Email: -unavailable-Open/Closed: Closed
Component Version: simulavr

Discussion locked!


(Jump to the original submission Jump to the original submission)

Mon May 20 08:59:50 2013, comment #7:

actual HEAD compiles with gcc 4.7.2 and avr-libc 1.8

Klaus Rudolph <zfrdh>
Project Administrator
Sun Mar 24 09:44:24 2013, comment #6:


ticket is now duplicate of #38536 and will be tracked there. Ticket closed.

cu, Thomas

Thomas K. <tomk>
Project Administrator
Mon Mar 12 14:43:41 2012, comment #5:

Just two small additional notes:

PROGMEM is defined in "avr/include/avr/pgmspace.h":
#define _ATTR_PROGMEM_ __attribute__((_progmem_))

and "prog_char" you can still find in "avr/include/avr/pgmspace.h":
typedef char PROGMEM prog_char;
typedef char prog_char _attribute_((_progmem_,deprecated("prog_char type is deprecated.")));

Hope it helps.

Mon Mar 12 14:35:23 2012, comment #4:

Note that I also fix "prog_char" in my changes.

There is only one place in the "./examples/atmel_key/scancodes.h" file which needs to be fixed. I change:
prog_char shifted[][2]
char shifted[][2] PROGMEM
where "PROGMEM" actually means "__attribute__((_progmem_))"

Mon Mar 12 13:24:10 2012, comment #3:

prog_char is something else to get rid of.
It's not supposed to work.
That it does is a compiler bug.
In avr-g++, it doesn't work.
That libc has it was a poor choice that causes occasional discussion on avrfreaks, especially when someone tries to use it with avr-g++.

Michael Hennebry <skeeve>
Project Member
Mon Mar 12 12:53:45 2012, comment #2:

I decided to add some small comments to my previous post.

Most of the changes, that I do, are "self-explanatory". You will get an "error: attempt to use poisoned SOME_MAGIC_NAME" if you do not apply them.

However, there are some changes in the "atmel_key" example which may need some additional explanation.

In the "./examples/atmel_key/main.c" file I replace the call to "msleep" with "_delay_ms", and in the "./examples/atmel_key/StdDefs.c" file I comment out the call to "_delay_ms" (in the "msleep" implementation - this makes this function unusable - it's "dummy" then - but it was ONLY used in one place in the "./examples/atmel_key/main.c" file, which I also patched).
The reason is that the "_delay_ms" accepts ONLY constant parameters, no variable parameters are allowed in the call. If you do not apply these changes, you will get "/.../avr/.../4.5.1/.../include/util/delay.h:164:28: error: __builtin_avr_delay_cycles expects an integer constant."

Hope it helps.

Sun Mar 11 23:47:31 2012, comment #1:

Here's what I had to do in order to get simulavr-1.0.0 compiled with avr-gcc-4.5.1 and avr-libc-1.8.0:

cd simulavr-1.0.0
find ./ -name "*" -type f -exec sed -i -e 's/SIG_INTERRUPT0/INT0_vect/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/SIG_INTERRUPT1/INT1_vect/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/SIG_INTERRUPT2/INT2_vect/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/SIG_OUTPUT_COMPARE2/TIMER2_COMP_vect/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/SIG_OUTPUT_COMPARE2A/TIMER2_COMPA_vect/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/SIG_OUTPUT_COMPARE3B/TIMER3_COMPB_vect/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/SIG_UART0_RECV/USART0_RX_vect/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/SIG_UART0_DATA/USART0_UDRE_vect/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/__attribute__((progmem))/PROGMEM/' \{\} \;
find ./ -name "*" -type f -exec sed -i -e 's/__attribute__ ((progmem))/PROGMEM/' \{\} \;
sed -i -e 's+prog_char shifted\[\]\[2\]+char shifted\[\]\[2\] PROGMEM+' ./examples/atmel_key/scancodes.h
sed -i -e 's+#include <avr/io.h>+#include <avr/io.h>\n#include <util/delay.h>+' ./examples/atmel_key/main.c
sed -i -e 's+msleep+_delay_ms+' ./examples/atmel_key/main.c
sed -i -e 's+_delay_ms+// _delay_ms+' ./examples/atmel_key/StdDefs.c

Hope it helps.

Tue Mar 6 22:38:47 2012, original submission:

gcc-4.6.3, avr-libc-1.8.0, simulavr-1.0.0: compilation of examples fails because the new gcc has old style interrupt vector names poisoned (example: SIG_INTERRUPT0 is bad, INT0_vect is good). Also prog_char is depreciated.

I have replaced the old style interrupt names with the new ones, and proc_char in examples/atmel_key/scancodes.h by a const char with attribute, now i can at least compile.

I don't know what downward compatibility issues result from these changes.
If you want i can create a patch.



No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by zfrdh (Posted a comment)
  • -unavailable- added by tomk (Posted a comment)
  • -unavailable- added by skeeve (Posted a comment)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon May 20 08:59:50 2013zfrdhStatusDuplicate=>Fixed
    Sun Mar 24 09:44:24 2013tomkStatusNone=>Duplicate
      Discussion LockUnlocked=>Locked

    Back to the top

    Powered by Savane 3.1-cleanup