Discussion:
[avr-libc-dev] [bug #45151] #define _ASM_SFR_COMPAT 1 and #include <avr/power.h> results in build error
anonymous
2015-05-20 14:49:06 UTC
Permalink
URL:
<http://savannah.nongnu.org/bugs/?45151>

Summary: #define _ASM_SFR_COMPAT 1 and #include <avr/power.h>
results in build error
Project: AVR C Runtime Library
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
Percent Complete: 0%
Assigned to: None
Originator Email: ***@gmail.com
Open/Closed: Open
Discussion Lock: Any
Release: 1.8.0
Fixed Release: None

_______________________________________________________

Details:

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





_______________________________________________________

Reply to this item at:

<http://savannah.nongnu.org/bugs/?45151>

_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
Pitchumani
2015-05-21 13:31:17 UTC
Permalink
Follow-up Comment #1, bug #45151 (project avr-libc):

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)

_______________________________________________________

Reply to this item at:

<http://savannah.nongnu.org/bugs/?45151>

_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
Urja Rannikko
2015-05-21 16:36:06 UTC
Permalink
Hi,

So i cant be bothered to reply at the bug because cant be bothered
making an account there and i dont think anybody will miss much if
they miss this.
Post by Pitchumani
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.
Yeah it was quite obviously clear.
After reporting this i actually thought it was a bit silly of me, but i was in
test-and-report-everything mode.

I heard you were considering a release so i thought it'd be nice to pre-test
my stuff. I'd guess it was good that this was the only thing i found :)
Some stuff compiles a bit bigger (by like 10-20 bytes) than with 4.9.2,
some smaller...
Post by Pitchumani
Possible solution maybe to include power.h conditionally (if not
_SFR_ASM_COMPAT)
This is actually a good idea even for my main header, thanks.

I dont care how the bug ends up going, if you want to fix it i'd say
#ifndef _SFR_ASM_COMPAT (or similar) in power.h around the functions
would be okay,
since you cant use any of the stuff anyways.

Loading...