Skip to content

Commit 63b6b63

Browse files
committed
build: Use character literals for generated headers to avoid narrowing
Use character literals instead of integer hex values (i.e. `'\x5b','\x0a', ...` instead of `0x5b, 0x0a, ...`) for generated headers. This avoids C++11 narrowing warnings in a more concise way than using explicit char casts. Extra whitespace is also removed between elements for brevity.
1 parent bb57017 commit 63b6b63

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cmake/script/GenerateHeaderFromJson.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmake_path(GET JSON_SOURCE_PATH STEM json_source_basename)
66

77
file(READ ${JSON_SOURCE_PATH} hex_content HEX)
88
string(REGEX REPLACE "................" "\\0\n" formatted_bytes "${hex_content}")
9-
string(REGEX REPLACE "[^\n][^\n]" "0x\\0, " formatted_bytes "${formatted_bytes}")
9+
string(REGEX REPLACE "[^\n][^\n]" "'\\\\x\\0'," formatted_bytes "${formatted_bytes}")
1010

1111
set(header_content
1212
"#include <string_view>

cmake/script/GenerateHeaderFromRaw.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmake_path(GET RAW_SOURCE_PATH STEM raw_source_basename)
66

77
file(READ ${RAW_SOURCE_PATH} hex_content HEX)
88
string(REGEX REPLACE "................" "\\0\n" formatted_bytes "${hex_content}")
9-
string(REGEX REPLACE "[^\n][^\n]" "std::byte{0x\\0}, " formatted_bytes "${formatted_bytes}")
9+
string(REGEX REPLACE "[^\n][^\n]" "std::byte{0x\\0}," formatted_bytes "${formatted_bytes}")
1010

1111
set(header_content
1212
"#include <cstddef>

0 commit comments

Comments
 (0)