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

Cannot include doctest.h in multiple translation units for Arduino (avr-gcc-7.3.0) #845

Open
anthonytw opened this issue Feb 26, 2024 · 0 comments

Comments

@anthonytw
Copy link

Description

I included unit tests inline in a few translation units. However, doing so throws the following link error, the source of which I haven't been able to track down:

File1.cpp.o (symbol from plugin): In function `sig_atomic_t':
(.text+0x0): multiple definition of `sig_atomic_t'
File2.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Error during build: exit status 1

While the type seems related to the signal headers, I haven't been able to isolate the source of the problem without breaking doctest.

Steps to reproduce

Include doctest.h with nothing else in two translation units. Compile. Cry.

Extra information

  • doctest version: v2.4.11
  • Operating System: Windows 11
  • Compiler+version: avr-gcc\7.3.0-atmel3.6.1-arduino7
@anthonytw anthonytw changed the title Cannot use in multiple translation units for Arduino (avr-gcc-7.3.0) Cannot include doctest.h in multiple translation units for Arduino (avr-gcc-7.3.0) Feb 26, 2024
@Delph
Copy link

Delph commented Apr 11, 2024

A doctest implementation inflates an otherwise empty binary by about 516KB without any optimisation flags on, and by about 155KB with -Os (gcc 9.4, c++11). Of the Arduino AVR boards, only the Mega can fit this (I think the ATmega2650 is the only one that can). The Uno and Nano only have 32KB of program storage.

Even if you addressed the size issue (or it isn't a problem for you), avr-gcc (and the Arduino Core libraries) are going to be missing a lot of functionality from the standard library because there is no need for it on a microcontroller.

Your best bet is to use an alternative that will fit onto and run on a microcontroller (a quick search revealed https://www.arduino.cc/reference/en/libraries/aunit/, I'm sure there are others).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants