[core] Use Arduino string macros only on ESP8266 (#12471)

This commit is contained in:
guillempages
2025-12-14 21:15:19 +01:00
committed by GitHub
parent 8524b894d6
commit cee532a1e3

View File

@@ -1,16 +1,16 @@
#pragma once
// Platform-agnostic macros for PROGMEM string handling
// On ESP32 (both Arduino and IDF): Use plain strings (no PROGMEM)
// On ESP8266/Arduino: Use Arduino's F() macro for PROGMEM strings
// On other platforms: Use plain strings (no PROGMEM)
#ifdef USE_ESP32
#define ESPHOME_F(string_literal) (string_literal)
#define ESPHOME_PGM_P const char *
#define ESPHOME_strncpy_P strncpy
#else
// ESP8266 and other Arduino platforms use Arduino macros
#ifdef USE_ESP8266
// ESP8266 uses Arduino macros
#define ESPHOME_F(string_literal) F(string_literal)
#define ESPHOME_PGM_P PGM_P
#define ESPHOME_strncpy_P strncpy_P
#else
#define ESPHOME_F(string_literal) (string_literal)
#define ESPHOME_PGM_P const char *
#define ESPHOME_strncpy_P strncpy
#endif