I’m trying to use new vscode-cpptools 1.8.0 (insider2) with integrated clang-tidy. And I was able to make it work but it requires some manual work.
The problem is when I run clang-tidy without modification than it has not enough flags to run correctly. So I run verbose pio check to see how it is done by pio itself and it seems that there are a lot of D__* flags added
/Users/lukas/.platformio/packages/tool-clangtidy/clang-tidy --quiet --checks=* /Users/lukas/dev/projects/sauna_meter/src/main.cpp -- -DPLATFORMIO=50203 -DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_WEMOS_D1MINIPRO -DF_CPU=80000000L -D__ets__ -DICACHE_FLASH -DARDUINO=10805 -DARDUINO_BOARD="PLATFORMIO_D1_MINI_PRO" -DFLASHMODE_DIO -DLWIP_OPEN_SRC -DNONOSDK22x_190703=1 -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DVTABLES_IN_FLASH -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -D__DBL_MIN_EXP__=(-1021) -D__cpp_attributes=200809L -D__cpp_nontype_template_parameter_auto=201606L -D__UINT_LEAST16_MAX__=0xffff -D__ATOMIC_ACQUIRE=2 -D__FLT_MIN__=1.1754943508222875e-38F -D__GCC_IEC_559_COMPLEX=0 -D__cpp_aggregate_nsdmi=201304L -D__UINT_LEAST8_TYPE__=unsigned char -D__INTMAX_C(c)=c ## LL -D__CHAR_BIT__=8 -D__UINT8_MAX__=0xff -D__WINT_MAX__=0xffffffffU -D__FLT32_MIN_EXP__=(-125) -D__cpp_static_assert=201411L -D__ORDER_LITTLE_ENDIAN__=1234
... and a lot of others
So I copied this command, do some parsing and I put all of these flags into c_cpp_properties.json in defines section.
"defines": [
>>> generated by PIO
"PLATFORMIO=50203",
"ESP8266",
"ARDUINO_ARCH_ESP8266",
"ARDUINO_ESP8266_WEMOS_D1MINIPRO",
"F_CPU=80000000L",
"__ets__",
"ICACHE_FLASH",
"ARDUINO=10805",
"ARDUINO_BOARD=\"PLATFORMIO_D1_MINI_PRO\"",
"FLASHMODE_DIO",
"LWIP_OPEN_SRC",
"NONOSDK22x_190703=1",
"TCP_MSS=536",
"LWIP_FEATURES=1",
"LWIP_IPV6=0",
"VTABLES_IN_FLASH",
"MMU_IRAM_SIZE=0x8000",
"MMU_ICACHE_SIZE=0x8000",
>>> added by ME
"__DBL_MIN_EXP__=(-1021)",
"__cpp_attributes=200809L",
"__cpp_nontype_template_parameter_auto=201606L",
"__UINT_LEAST16_MAX__=0xffff",
... and a lot of others
Than I set executable to pio clang-tidy and it start working unless properties are regenerated (its not a big deal, I can write some watcher and replace it again).
Is it possible to generate defines with this flags automatically ? Or to integrate it in more elegant way ?