Compiler difference arduino ide vs platformio

hello all,

i spotted a bizarre behaviour of the two different compilers of the arduino ide and platformio.

if i code this:

const byte aliasName = 4;

struct
{
  byte test: aliasName;
}

the pio compiler tells me this way it isnt possible cuz the expression should be a constant value. its possible to upload cuz it should be a warning only and also it works. the same code the arduino ide compile without this warning and upload also works. its just annoying and i want to know why this happen. can someone tell me please.

thanks and hugs :slight_smile:

By default, warnings are not displayed in the Arduino IDE. Have you enabled verbose output in the preferences?

Additionally, the Arduino IDE uses different compiler settings. In particular, it checks for fewer potential problems and emits fewer warnings. So even if you enable verbose output, you might get less warnings than with PlatformIO.

In short: the Arduino IDE makes you feel good by hiding warnings. But there is a potential problem in your code anyway.

1 Like

This highly depends on what platform you’re compiling for. What’s the platformio.ini?

1 Like

What is the exact code you used / i.e. a minimum complete verifiable example?

as

#include <Arduino.h>

const byte aliasName = 4;

struct testStruct
{
  byte test: aliasName;
};

testStruct test;

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(test.test);
  delay(1000);
}

does not give me any warnings from for a AVR board (uno) on PlatformIO, nor with the Arduino IDE with all warnings turned on.