Strange issue with compiling: under Linux fine, fails badly in Windows

Dead giveaway that this is due to Windows’ filesystem, which is case-insensitive, as opposed to Linux, which is usually (ext4 etc.) case sensitive.

So, if e.g. the Helios project has some header file called stream.h while Arduino has Stream.h, and some code tries to #include <stream.h>, on Windows, since upper and lowercasing doens’t matter, it can’t correctly know which header file was meant.

If you look closely at an error message, exactly that is revealed:

In file included from .pio\libdeps\megaatmega2560\HeliOS\src/device.h:24:0,
                 from .pio\libdeps\megaatmega2560\HeliOS\src/port.h:23,
                 from .pio\libdeps\megaatmega2560\HeliOS\src/Stream.h:23,
                 from C:\Users\Max\.platformio\packages\framework-arduino-avr\libraries\Wire\src/Wire.h:27,
                 from .pio\libdeps\megaatmega2560\Adafruit BusIO/Adafruit_I2CDevice.h:5,
                 from .pio\libdeps\megaatmega2560\Adafruit GFX Library/Adafruit_GFX.h:12,
                 from src\main.cpp:4:
.pio\libdeps\megaatmega2560\HeliOS\src/mem.h:35:12: error: conflicting declaration of C function 'Return_t xMemFree(const volatile Addr_t*)'

It should immediately stand out that Wire.h includes the Stream.h from HelIOS, although the Arduino layer should not directly include HeliOS at all. And, when you look in the files

It’s immeidately visible that stream.h in HeliOS conflicts with Stream.hof the Arduino core.

To resolve this conflict, the library can be forked and the filenames and references can be changed to not conflict anymore. See e.g. here.

So,

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
monitor_speed = 115200
lib_deps = 
	https://github.com/maxgerhardt/HeliOS/archive/refs/heads/master.zip
	adafruit/Adafruit GFX Library@^1.11.3
	cmb27/ModbusRTUMaster@^1.0.5
lib_ldf_mode = chain
lib_compat_mode = soft

together with code


#include <Arduino.h>
#include <HeliOS.h>
#include <Adafruit_GFX.h>
#include <ModbusRTUMaster.h>

void setup() {
  if(ERROR(xSystemInit())) {
    xSystemHalt();
  }
  if(ERROR(xTaskStartScheduler())) {
    xSystemHalt();
  }
  xSystemHalt();
}

void loop() {}

compiles fine on Windows.

Linking .pio\build\megaatmega2560\firmware.elf
Checking size .pio\build\megaatmega2560\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  13.0% (used 1061 bytes from 8192 bytes)
Flash: [          ]   0.4% (used 1054 bytes from 253952 bytes)
Building .pio\build\megaatmega2560\firmware.hex
===================[SUCCESS] Took 33.56 seconds ===================
3 Likes