Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ target_sources(
include/stdx/cx_vector.hpp
include/stdx/detail/bitset_common.hpp
include/stdx/detail/fmt.hpp
include/stdx/detail/freestanding.hpp
include/stdx/detail/list_common.hpp
include/stdx/env.hpp
include/stdx/for_each_n_args.hpp
Expand Down
8 changes: 7 additions & 1 deletion include/stdx/detail/fmt.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#pragma once

#if not STDX_FMT_FREESTANDING
#include <stdx/detail/freestanding.hpp>

// NOLINTBEGIN(cppcoreguidelines-macro-usage)

#ifndef STDX_FREESTANDING

#include <fmt/compile.h>
#include <fmt/format.h>
Expand Down Expand Up @@ -172,3 +176,5 @@ CONSTEVAL auto format_to(It dest, auto fmtstr, auto v) -> void {
} // namespace stdx

#endif

// NOLINTEND(cppcoreguidelines-macro-usage)
5 changes: 5 additions & 0 deletions include/stdx/detail/freestanding.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#ifdef SIMULATE_FREESTANDING
#define STDX_FREESTANDING
#endif
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)
warnings
stdx)
target_compile_definitions(ct_format_freestanding_test
PRIVATE -DSTDX_FMT_FREESTANDING=1)
PRIVATE STDX_FREESTANDING)
endif()

add_subdirectory(fail)
Expand Down
2 changes: 1 addition & 1 deletion test/ct_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TEST_CASE("format a compile-time argument with different base", "[ct_format]") {
"Hello 0x2a"_fmt_res);
}

#if not STDX_FMT_FREESTANDING
#ifndef STDX_FREESTANDING
TEST_CASE("format a compile-time argument with fmt spec", "[ct_format]") {
STATIC_REQUIRE(stdx::ct_format<"Hello {:*>#6x}">(CX_VALUE(42)) ==
"Hello **0x2a"_fmt_res);
Expand Down
2 changes: 1 addition & 1 deletion usage_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ cpmaddpackage(NAME stdx SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/.." GIT_TAG HEAD)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE stdx)
if(CPP_IMPLEMENTATION STREQUAL "FREESTANDING")
target_compile_definitions(app PRIVATE STDX_FMT_FREESTANDING)
target_compile_definitions(app PRIVATE SIMULATE_FREESTANDING)
target_compile_options(app PRIVATE -ffreestanding)
endif()