Skip to content

Fix _SFR_IO8 macro to avoid "cannot take the address of an rvalue" #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ianfixes opened this issue Oct 26, 2020 · 3 comments · Fixed by #183
Closed

Fix _SFR_IO8 macro to avoid "cannot take the address of an rvalue" #187

ianfixes opened this issue Oct 26, 2020 · 3 comments · Fixed by #183
Labels
arduino mocks Compilation mocks for the Arduino library bug Something isn't working

Comments

@ianfixes
Copy link
Collaborator

Issue Summary

see Arduino-CI/SD#2

error: cannot take the address of an rvalue of type 'int'
  {&DDRE, &PINE, &PORTE, 0},  // E0  0
   ^~~~~

Working theory is that this is caused by a badly formed macro.

https://github.com/Arduino-CI/arduino_ci/blob/master/cpp/arduino/avr/io.h#L99

- #define _SFR_IO8(io_addr) (io_addr) // this macro is all we need from the sfr file 
+ #define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))
+ #define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)

Will see if volatile is sufficient to fix

@ianfixes ianfixes added arduino mocks Compilation mocks for the Arduino library bug Something isn't working labels Oct 26, 2020
@jgfoster
Copy link
Member

Also see #120. I copied code from there and got things to compile.

@ianfixes
Copy link
Collaborator Author

I was able to reproduce this with a unit test, and added the volatile keyword (and cast) to fix the error. Currently in my feature branch.

@ianfixes
Copy link
Collaborator Author

ianfixes commented Nov 4, 2020

This took a lot longer than expected due to chasing my tail on linker errors (and segfaults). I think I am out of the woods now though.

jgfoster pushed a commit to jgfoster/arduino_ci that referenced this issue Nov 9, 2020
jgfoster pushed a commit to jgfoster/arduino_ci that referenced this issue Nov 9, 2020
* Increase clarity of command line tool: The command line option --skip-compilation can be confusing, because unit tests must be compiled before they can run.  This adds some text to the flag such that the fact that examples are compiled is acknowledged.
* Use proper 1.5 library format
* Obey 1.0 / 1.5 library specification when finding C++ library source
* Appease rubocop
* avoid error when testing for membership in a nonexistent directory
* Add library.properties parsing
* Add recursive library dependency compilation
* Fix unit tests for source directory exclusion
* reorder changelog sections
* Fix _SFR_IO8 macro definition -- use volatile keyword to prevent optimization
* Add dummy test files to sample projects to ensure they aren't included in C++ file listings
* Print unit test stack traces if encountered
* Fix definition of SFR macro to prevent linker errors about duplicate symbol
* Explore possible fix for Arduino-CI#187.
* Tests now pass (but only because of a horrible hack by someone who doesn't understand what is happening!).

Co-authored-by: Ian Katz <ianfixes@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arduino mocks Compilation mocks for the Arduino library bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants