Fix import std
in clang++
#4488
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
#define FMT_IMPORT_STD
,{fmt}
will doimport std
instead of#include <std...>
. However this is currently broken on clang++. This PR fixes:memcpy
,memcmp
,abort
when importing std. Fix it by adding#include <string.h>
and#include <stdlib.h>
in global module.include/fmt/std.h
usesstd::__bit_const_reference
which is not exported by libc++ and cannot be found. Guard it by macros.BTW, we can import C std symbols by
import std.compat
, and in this case we do not need the<limits.h>
,<stdint.h>
... as well. So that I add an optionalFMT_IMPORT_STD_COMPAT
macro to tell{fmt}
whetherimport std.compat
.Thank you!