Skip to content
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

Arduino.h and avr stdlib "conflicting declaration of C function" #475

Open
electronjoe opened this issue May 5, 2022 · 0 comments · May be fixed by #572
Open

Arduino.h and avr stdlib "conflicting declaration of C function" #475

electronjoe opened this issue May 5, 2022 · 0 comments · May be fixed by #572
Labels

Comments

@electronjoe
Copy link

electronjoe commented May 5, 2022

Context

I'm working to get a Visual Studio Code Devcontainer up and running with a Bazel build for Arduboy. I've pushed my current (problematic - per this GH issue) effort to my arduboy_bazel repo.

If you wanted to play with it you could:

  • Check out the repo
  • Install Docker Desktop
  • Open directory in VS Code and install the VS Code Remote - Containers extension
  • Restart vs code?
  • F1 -> Remote-Containers: Rebuild and open in Container
  • Wait for the container to build
  • Open terminal in VS Code
  • bazel build //example:buttons --config=avr --verbose_failures --sandbox_debug
  • Or for verbose action output
  • bazel aquery //example:buttons --config=avr --verbose_failures --sandbox_debug

Alternatively you can dev entirely in the cloud and skip the vs code install / extension install by using the (free for ~40 hours per month) gitpod.io in your browser, point it at my repo.

I'm having trouble getting past the following compiler error in building an example Arduboy demo I've copied into my repo (buttons.cpp) see ref.

Versions

  • I'm installing all avr tooling & stdlib using the github.com/arduino/toolchain-avr repo branch 7.3.0-atmel3.6.1-arduino7 See here
vscode ➜ /workspaces/arduboy_bazel (main ✗) $ /home/vscode/toolchain-avr/objdir/bin/avr-g++ --version
avr-g++ (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • I'm using github.com/arduino/ArduinoCore-avr at tag 1.8.5 See here

Compilation Command

bazel build //example:buttons --config=avr --verbose_failures --sandbox_debug

/home/vscode/toolchain-avr/objdir/bin/avr-g++ -MD -MF bazel-out/avr-fastbuild/bin/example/_objs/buttons/main.d '-frandom-seed=bazel-out/avr-fastbuild/bin/example/_objs/buttons/main.o' -iquote . -iquote bazel-out/avr-fastbuild/bin -iquote external/arduboy2 -iquote bazel-out/avr-fastbuild/bin/external/arduboy2 -iquote external/arduinocore_avr -iquote bazel-out/avr-fastbuild/bin/external/arduinocore_avr -iquote external/bazel_tools -iquote bazel-out/avr-fastbuild/bin/external/bazel_tools -isystem external/arduboy2/src -isystem bazel-out/avr-fastbuild/bin/external/arduboy2/src -isystem external/arduinocore_avr/cores/arduino -isystem bazel-out/avr-fastbuild/bin/external/arduinocore_avr/cores/arduino -isystem external/arduinocore_avr/variants/leonardo -isystem bazel-out/avr-fastbuild/bin/external/arduinocore_avr/variants/leonardo -isystem external/arduinocore_avr/libraries/EEPROM/src -isystem bazel-out/avr-fastbuild/bin/external/arduinocore_avr/libraries/EEPROM/src '-mmcu=atmega32u4' '-DF_CPU=16000000L' '-DARDUINO=10819L' -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR '-DUSB_VID=0x2341' '-DUSB_PID=0x8036' '-DUSB_MANUFACTURER="Arduboy"' '-DUSB_PRODUCT="Arduboy_FX"' -g -Os -w '-std=gnu++11' -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics '-Wno-error=narrowing' -flto -w -x c++ -CC -c external/arduinocore_avr/cores/arduino/main.cpp -o bazel-out/avr-fastbuild/bin/example/_objs/buttons/main.o

Error

In file included from external/arduinocore_avr/cores/arduino/main.cpp:20:0:
external/arduinocore_avr/cores/arduino/Arduino.h:132:5: error: conflicting declaration of C function 'int atexit(void (*)(...))'
 int atexit(void (*func)()) __attribute__((weak));
     ^~~~~~
In file included from external/arduinocore_avr/cores/arduino/Arduino.h:23:0,
                 from external/arduinocore_avr/cores/arduino/main.cpp:20:
/home/vscode/toolchain-avr/objdir/avr/include/stdlib.h:685:12: note: previous declaration 'int atexit(void (*)())'
 extern int atexit(void (*)(void));
            ^~~~~~

And many more with similar root cause - Full errors.

Thoughts

Are there conflicting function declarations for a number of avr stdlib functions, redefined in arduinocore_avr's Arduino.h?

Is my compilation mistreating C / C++ headers in some way?

Do you see anything I'm doing wrong here?

Thanks for any assistance!

@per1234 per1234 added the bug label May 9, 2022
@Ebola-Chan-bot Ebola-Chan-bot linked a pull request Oct 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants