Skip to content

Commit 4d468ed

Browse files
authored
Merge pull request #290 from elbeno/finesse-freestanding
🎨 Provide better control over freestanding
2 parents 7a0cfd1 + 1721031 commit 4d468ed

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ target_sources(
6161
include/stdx/cx_vector.hpp
6262
include/stdx/detail/bitset_common.hpp
6363
include/stdx/detail/fmt.hpp
64+
include/stdx/detail/freestanding.hpp
6465
include/stdx/detail/list_common.hpp
6566
include/stdx/env.hpp
6667
include/stdx/for_each_n_args.hpp

include/stdx/detail/fmt.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#pragma once
22

3-
#if not STDX_FMT_FREESTANDING
3+
#include <stdx/detail/freestanding.hpp>
4+
5+
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
6+
7+
#ifndef STDX_FREESTANDING
48

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

174178
#endif
179+
180+
// NOLINTEND(cppcoreguidelines-macro-usage)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
3+
#ifdef SIMULATE_FREESTANDING
4+
#define STDX_FREESTANDING
5+
#endif

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)
9595
warnings
9696
stdx)
9797
target_compile_definitions(ct_format_freestanding_test
98-
PRIVATE -DSTDX_FMT_FREESTANDING=1)
98+
PRIVATE STDX_FREESTANDING)
9999
endif()
100100

101101
add_subdirectory(fail)

test/ct_format.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ TEST_CASE("format a compile-time argument with different base", "[ct_format]") {
106106
"Hello 0x2a"_fmt_res);
107107
}
108108

109-
#if not STDX_FMT_FREESTANDING
109+
#ifndef STDX_FREESTANDING
110110
TEST_CASE("format a compile-time argument with fmt spec", "[ct_format]") {
111111
STATIC_REQUIRE(stdx::ct_format<"Hello {:*>#6x}">(CX_VALUE(42)) ==
112112
"Hello **0x2a"_fmt_res);

usage_test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ cpmaddpackage(NAME stdx SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/.." GIT_TAG HEAD)
1212
add_executable(app main.cpp)
1313
target_link_libraries(app PRIVATE stdx)
1414
if(CPP_IMPLEMENTATION STREQUAL "FREESTANDING")
15-
target_compile_definitions(app PRIVATE STDX_FMT_FREESTANDING)
15+
target_compile_definitions(app PRIVATE SIMULATE_FREESTANDING)
1616
target_compile_options(app PRIVATE -ffreestanding)
1717
endif()

0 commit comments

Comments
 (0)