Skip to content

Include <string> (and <cassert>/<cstdint>) directly in Lua.h - #1

Open
ACEFGI wants to merge 1 commit into
Fischer-Simon:mainfrom
ACEFGI:fix/lua-header-missing-string-include
Open

ACEFGI wants to merge 1 commit into
Fischer-Simon:mainfrom
ACEFGI:fix/lua-header-missing-string-include

Conversation

@ACEFGI

@ACEFGI ACEFGI commented Jun 11, 2026

Copy link
Copy Markdown

Problem

Lua.h uses several standard-library facilities without including the headers that declare them:

  • std::string — used throughout the Arg class (constructors, the m_strVal union member, getStrVal())
  • assert() — used in getStrVal() / getIntVal() / getFloatVal()
  • uint8_t — used for the Arg::Type enum's underlying type

These currently resolve only through transitive includes pulled in by <mutex> and <vector>. That happens to work with the libstdc++ shipped in the Arduino-ESP32 2.x core (gcc 8), but breaks with newer toolchains. Under gcc 14 (pioarduino), <string> is no longer included transitively, so building against this header fails with errors like 'string' is not a member of 'std'.

Downstream projects have had to work around this by force-including <string> from a PlatformIO extra script.

Fix

Include the required headers directly in Lua.h so it is self-contained and no longer depends on the include graph of unrelated standard headers:

  • <string>
  • <cassert>
  • <cstdint>

Also tidied a stray leading space on the first #include line.

No functional change — this only makes the existing dependencies explicit.

Lua.h uses std::string (the Arg class), assert(), and uint8_t but
relied on transitive includes via <mutex>/<vector> to provide them.
That worked under gcc 8 but breaks under gcc 14, where <string> is no
longer pulled in transitively, causing compile failures in downstream
projects.

Include the headers directly so Lua.h is self-contained.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant