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
7 changes: 0 additions & 7 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,3 @@ if(PLOTLYPP_BUILD_MODULES)
endif()

set_target_warnings(example)
target_compile_options(example PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
# Clang complains with -Wpedantic. For external users we also have the PLOTLYPP_SYSTEM_INCLUDE CMake option
# to treat all plotlypp headers as system headers.
-Wno-overlength-strings
>
)
7 changes: 7 additions & 0 deletions generator/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,13 @@ def package_js() -> None:

writer = Writer(Path(__file__).parent.parent / "include" / "plotlypp" / "plotly_min_js.hpp")
emit_preamble(writer)
writer.write("#include <plotlypp/warnings.hpp>")
writer.write("")
writer.write("namespace plotlypp {")
writer.write("")
writer.write("PLOTLYPP_DISABLE_WARNING_PUSH")
writer.write("PLOTLYPP_DISABLE_WARNING_OVERLENGTH_STRINGS")
writer.write("")
writer.write("// Note: constexpr string_view excessively bloats compile times due to length counts.")
writer.write(
"// Note: Plotly JS is chunked into multiple raw string literals to support MSVC limits, and 0x1a characters are escaped to avoid MSVC trating them as EOF."
Expand Down Expand Up @@ -900,6 +905,8 @@ def find_safe_delimiter(chunk: str) -> str:
writer.write('"\\x1a"')
writer.write(";")
writer.write("")
writer.write("PLOTLYPP_DISABLE_WARNING_POP")
writer.write("")
writer.write("} // namespace plotlypp")
writer.close()

Expand Down
7 changes: 7 additions & 0 deletions include/plotlypp/plotly_min_js.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@

#pragma once

#include <plotlypp/warnings.hpp>

namespace plotlypp {

PLOTLYPP_DISABLE_WARNING_PUSH
PLOTLYPP_DISABLE_WARNING_OVERLENGTH_STRINGS

// Note: constexpr string_view excessively bloats compile times due to length counts.
// Note: Plotly JS is chunked into multiple raw string literals to support MSVC limits, and 0x1a characters are escaped to avoid MSVC trating them as EOF.
inline constexpr const char* const plotlyJS =
Expand Down Expand Up @@ -5032,4 +5037,6 @@ return Plotly;
}));)d0"
;

PLOTLYPP_DISABLE_WARNING_POP

} // namespace plotlypp
28 changes: 28 additions & 0 deletions include/plotlypp/warnings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2025-2026 Jimmy O'Rourke
// Licensed under and subject to the terms of the LICENSE file accompanying this distribution.
// Official repository: https://github.com/jimmyorourke/plotlypp

#pragma once

#if defined(_MSC_VER)
#define PLOTLYPP_DISABLE_WARNING_PUSH __pragma(warning(push))
#define PLOTLYPP_DISABLE_WARNING_POP __pragma(warning(pop))
#define PLOTLYPP_DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber))

// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2026
#define PLOTLYPP_DISABLE_WARNING_OVERLENGTH_STRINGS

#elif defined(__GNUC__) || defined(__clang__)
#define PLOTLYPP_DO_PRAGMA(X) _Pragma(#X)
#define PLOTLYPP_DISABLE_WARNING_PUSH PLOTLYPP_DO_PRAGMA(GCC diagnostic push)
#define PLOTLYPP_DISABLE_WARNING_POP PLOTLYPP_DO_PRAGMA(GCC diagnostic pop)
#define PLOTLYPP_DISABLE_WARNING(warningName) PLOTLYPP_DO_PRAGMA(GCC diagnostic ignored warningName)

#define PLOTLYPP_DISABLE_WARNING_OVERLENGTH_STRINGS PLOTLYPP_DISABLE_WARNING("-Woverlength-strings")

#else
#define PLOTLYPP_DISABLE_WARNING_PUSH
#define PLOTLYPP_DISABLE_WARNING_POP

#define PLOTLYPP_DISABLE_WARNING_OVERLENGTH_STRINGS
#endif