Fix import std in clang++#4488
Merged
vitaut merged 4 commits intofmtlib:masterfrom Jul 7, 2025
shyeyian:master
Merged
Conversation
vitaut
requested changes
Jul 6, 2025
Contributor
vitaut
left a comment
There was a problem hiding this comment.
Thanks for the PR. The fixes LGTM but I don't think we need to add another configuration macro (FMT_IMPORT_STD_COMPAT).
This reverts commit 3d9bb8a.
Author
Okay, I've reverted that :) |
Contributor
|
Merged, thanks! |
import std in clang++, and add options for import std.compatimport std in clang++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 stdinstead of#include <std...>. However this is currently broken on clang++. This PR fixes:memcpy,memcmp,abortwhen importing std. Fix it by adding#include <string.h>and#include <stdlib.h>in global module.include/fmt/std.husesstd::__bit_const_referencewhich 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_COMPATmacro to tell{fmt}whetherimport std.compat.Thank you!