Skip to content

[Build] Add missing <stdlib.h> include for atoi - #2027

Open
nuclearcat wants to merge 1 commit into
intel:masterfrom
nuclearcat:build-missing-stdlib-include
Open

[Build] Add missing <stdlib.h> include for atoi#2027
nuclearcat wants to merge 1 commit into
intel:masterfrom
nuclearcat:build-missing-stdlib-include

Conversation

@nuclearcat

Copy link
Copy Markdown

PFParser::getToken() calls atoi() but cm_printf_host.cpp includes only project headers. The declaration has been arriving transitively through the standard library headers those pull in.

libc++ has been removing such transitive includes release by release. Under LLVM 22 with -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES=1 the path is gone and the file no longer compiles:

cmrtlib/agnostic/share/cm_printf_host.cpp:226:43: error: use of
undeclared identifier 'atoi'

Include <stdlib.h> directly. The call site is unqualified atoi() rather than std::atoi(), and <stdlib.h> is what the rest of the tree uses, so it is preferred here over .
Sorry for PR message being much longer than patch.

PFParser::getToken() calls atoi() but cm_printf_host.cpp includes only
project headers. The declaration has been arriving transitively through
the standard library headers those pull in.

libc++ has been removing such transitive includes release by release.
Under LLVM 22 with -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES=1 the path is
gone and the file no longer compiles:

  cmrtlib/agnostic/share/cm_printf_host.cpp:226:43: error: use of
      undeclared identifier 'atoi'

Include <stdlib.h> directly. The call site is unqualified atoi() rather
than std::atoi(), and <stdlib.h> is what the rest of the tree uses, so
it is preferred here over <cstdlib>.
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