bugAVR C Runtime Library - Bugs: bug #45151, #define _ASM_SFR_COMPAT 1 and...


bug #45151: #define _ASM_SFR_COMPAT 1 and #include <avr/power.h> results in build error

Submitted by:  None
Submitted on:  Wed 20 May 2015 02:49:05 PM UTC  
Category:  Header Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Assigned to:  None
Percent Complete:  0% Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  1.8.0
Fixed Release:  None

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 21 May 2015 01:31:16 PM UTC, comment #1: 

If _SFR_ASM_COMPAT is defined, you can't use any of the macros/ functions from power.h. Now __power_all_enable/disable are modified as inline function, so those functions are expanded where power.h is included and caused these errors.

Possible solution maybe to include power.h conditionally (if not _SFR_ASM_COMPAT)

Pitchumani <pitchumani>
Project Member
Wed 20 May 2015 02:49:05 PM UTC, original submission:  

Note: release field is incorrect, but there isnt one for newest svn.
I was testing current trunk avr-libc + current gcc 5 branch
(20.5.2015, avr-libc r2475) against my projects when i found this.

I simplified it as:

$ cat simple.c
#define _SFR_ASM_COMPAT 1
#include <avr/io.h>
#include <avr/power.h>

void main(void) { }

$ avr-gcc -mmcu=atmega328p -Os simple.c
In file included from simple.c:3:0:
/home/urjaman/avrtc-test/avr/include/avr/power.h: In function '__power_all_enable':
/home/urjaman/avrtc-test/avr/include/avr/power.h:1152:9: error: lvalue required as left operand of assignment
     PRR &= (uint8_t)~(__AVR_HAVE_PRR);
/home/urjaman/avrtc-test/avr/include/avr/power.h: In function '__power_all_disable':
/home/urjaman/avrtc-test/avr/include/avr/power.h:1201:9: error: lvalue required as left operand of assignment
     PRR |= (uint8_t)(__AVR_HAVE_PRR);

I think this might have been officially not supported, but it used to work without error.

I worked around by not including <avr/power.h> in the module that uses _ASM_SFR_COMPAT (has a few variable definitions and an ASM ISR and some C helpers to interface with the variables (and thus the ISR)), but it is slightly annoying for a project where all system includes used to in one main.h (another .c needed to include <avr/power.h> then).



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by pitchumani (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)



    No changes have been made to this item

    Back to the top

    Powered by Savane 3.5