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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

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

Submitter:  None
Submitted:  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

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>
Group 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).

Anonymous

 

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

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.13-3230.
    Corresponding source code