platformio / platform-espressif8266

Espressif 8266: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif8266
Apache License 2.0
320 stars 218 forks source link

arduino: clangtidy breaks if --extra-arg=-std=c++17 is passed #310

Open vanyasem opened 7 months ago

vanyasem commented 7 months ago

Configuration

Operating system: macOS 13.6.1 (Intel)

PlatformIO Version: PlatformIO Core, version 6.1.11

Espressif 8266 Version: 4.2.1

Description of problem

Steps to Reproduce

  1. Create a project with platform: espressif8266 and framework: arduino
  2. Configure clangtidy as a check_tool in platformio.ini
  3. Write some c++ code with clangtidy warnings (for example, define a magic number: 60.0 is a magic number; consider replacing it with a named constant)
  4. Use c++17 features in your code. For example, define an inline constexpr
  5. Run pio check - clangtidy will report using c++17 features as a warning: [medium:warning] inline variables are a C++17 extension [clang-diagnostic-c++17-extensions] together with other warnings of the project
  6. Add --extra-arg=-std=c++17 as a flag for clangtidy
  7. Run pio check again

Actual Results

clangtidy exits immediately, and does not find any warnings: clangtidy PASSED 00:00:00.247

pio check -v without --extra-arg=-std=c++17: no-extra-args.log

pio check -v with --extra-arg=-std=c++17: extra-args.log

Expected Results

clangtidy reports all warnings except for c++17 warnings

If problems with PlatformIO Build System:

The content of platformio.ini:

[env]
framework = arduino
build_flags = 
    -std=c++17
check_tool = clangtidy
check_flags = --checks=* --extra-arg=-std=c++17

[env:esp_wroom_02]
platform = espressif8266
; Any board triggers the same issue
board = esp_wroom_02

Source file to reproduce issue:

#include <Arduino.h>

inline constexpr int cpp17_warning = 123; // Will trigger a c++17 warning

void setup()
{
  delay(500); // Will trigger a Magic number warning
}

Additional info

The issue seems to be only reproducible when using the arduino framework. esp8266-nonos-sdk and esp8266-rtos-sdk frameworks did not suffer from the same issue.

The issue seems related to espressif8266 platform, as the issue is not reproducible on atmelavr or espressif32 platforms using arduino framework.