Skip to content

Library compile error when using Arduino CI #2

Closed
@jgfoster

Description

@jgfoster
Member

The command bundle exec arduino_ci_remote.rb --skip-unittests shows that all the examples compile fine in the Arduino IDE. But when I run bundle exec arduino_ci_remote.rb --skip-compilation I get error: cannot take the address of an rvalue of type 'int' (see below).

DDRE comes from #define DDRE _SFR_IO8(0x0D) which uses #define _SFR_IO8(io_addr) (io_addr). So, it appears that the code is trying to do something like
volatile uint8_t* ddr = &0x0D;,
which does seem odd. Perhaps 0x0D is supposed to be an address?

@ianfixes, @per1234, do you have any advice?

Note that this is where I ran into #186.

Last command:  $ g++ -std=c++0x -o /Users/jfoster/Documents/Arduino/libraries/SD/unittest_test.cpp.bin -DARDUINO=100 -g -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address -D__AVR_ATmega2560__ -DARDUINO_CI -D__AVR__ -I/Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/arduino -I/Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/unittest -I/Users/jfoster/Documents/Arduino/libraries/SD/src -I/Users/jfoster/Documents/Arduino/libraries/SD/src/utility /Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/arduino/Arduino.cpp /Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/arduino/Godmode.cpp /Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/arduino/stdlib.cpp /Users/jfoster/Documents/Arduino/libraries/SD/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/unittest/ArduinoUnitTests.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/File.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/SD.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/Sd2Card.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/SdFile.cpp /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/SdVolume.cpp /Users/jfoster/Documents/Arduino/libraries/SD/test/test.cpp

In file included from /Users/jfoster/Documents/Arduino/libraries/SD/src/File.cpp:15:
In file included from /Users/jfoster/Documents/Arduino/libraries/SD/src/SD.h:20:
In file included from /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/SdFat.h:29:
In file included from /Users/jfoster/Documents/Arduino/libraries/SD/src/utility/Sd2Card.h:26:
/Users/jfoster/Documents/Arduino/libraries/SD/src/utility/Sd2PinMap.h:78:4: error: cannot take the address of an rvalue of type 'int'
  {&DDRE, &PINE, &PORTE, 0},  // E0  0
   ^~~~~

Activity

jgfoster

jgfoster commented on Oct 25, 2020

@jgfoster
MemberAuthor

I think this may be related to Arduino CI #120. I've been able to work around the problem with some code proposed there.

ianfixes

ianfixes commented on Oct 26, 2020

@ianfixes

Looks like fun. The bug in my code is likely here: 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

DDRE points to this macro in various board definitions:

#define DDRE    _SFR_IO8(0x0D)

Which results in my implementation produces this nonsense for &DDRE: &(0x0D).

According to this forum post that should really be based on these 2 macros:

#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))
#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)

So my initial thought is that this can be fixed with some type of cast, possibly involving a reference to a statically-allocated array. I'll have to think more about that, and definitely add a unit test to prevent regressing it.

added
bugSomething isn't working
and removed
bugSomething isn't working
on Oct 26, 2020
ianfixes

ianfixes commented on Oct 27, 2020

@ianfixes

Just to be clear here, was this issue supposed to be opened against SD and not arduino_ci?

jgfoster

jgfoster commented on Oct 27, 2020

@jgfoster
MemberAuthor

I started here because I wasn't sure where the problem was and because I thought that even if the problem was in arduino_ci I would need to implement a work-around. So, maybe this should stay open to track the fix in the framework so I can remove my "hack".

jgfoster

jgfoster commented on Nov 27, 2020

@jgfoster
MemberAuthor

Seems to be working fine with 0.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ianfixes@jgfoster

        Issue actions

          Library compile error when using Arduino CI · Issue #2 · Arduino-CI/SD