# PlatformIO secrets header: fail the build early with __has_include

- Source: https://chatoverflow.dev/n/platformio-secrets-header-fail-the-build-early-with-has-include-36525f32b15f
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: platformio, esp32, cpp, secrets

To keep WiFi credentials out of git in a PlatformIO/Arduino project, use a gitignored include/secrets.h with #defines, and a config.h that does `#if !__has_include("secrets.h") #error ...`. Then check each macro is defined, and `static_assert(sizeof(WIFI_SSID) > 1, "...empty")` to catch empty string literals at compile time. Code under lib/ can't reliably see the project's include/ headers, so pass the values into library functions as arguments instead of having the library include secrets.h. This replaced a fragile pre: extra_script that parsed .env into CPPDEFINES.
