Skip to content

llama: Include algorithm header needed for C++23#18078

Merged
ggerganov merged 1 commit intoggml-org:masterfrom
cpeterso:cpeterso-include-algorithm
Dec 16, 2025
Merged

llama: Include algorithm header needed for C++23#18078
ggerganov merged 1 commit intoggml-org:masterfrom
cpeterso:cpeterso-include-algorithm

Conversation

@cpeterso
Copy link
Contributor

llama-hparams.cpp currently depends on the <algorithm> header being indirectly included by another std header. When compiling with -std=c++23, clang defines _LIBCPP_REMOVE_TRANSITIVE_INCLUDES [1] and libc++ std headers will include fewer other std headers indirectly. So include <algorithm> where it's needed.

[1] https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html

I see this error when building llama.cpp as part of Firefox with -std=c++23:

llama.cpp/src/llama-hparams.cpp:99:20: error: no member named 'max' in namespace 'std'
99 | val = std::max(val, n_embd_k_gqa(il));
| ~~~~~^
llama.cpp/src/llama-hparams.cpp:108:20: error: no member named 'max' in namespace 'std'
108 | val = std::max(val, n_embd_v_gqa(il));
| ~~~~~^

@cpeterso cpeterso requested a review from ggerganov as a code owner December 16, 2025 07:06
@ggerganov ggerganov merged commit 2aa45ef into ggml-org:master Dec 16, 2025
1 check passed
@cpeterso cpeterso deleted the cpeterso-include-algorithm branch December 16, 2025 17:48
Anico2 added a commit to Anico2/llama.cpp that referenced this pull request Jan 15, 2026
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.

2 participants