1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-22 18:28:53 -05:00

-Wformat-nonliteral

This commit is contained in:
Evan Pezent 2022-01-30 10:06:39 -08:00
parent 168244e422
commit 8d3bd31395
2 changed files with 25 additions and 6 deletions

View File

@ -122,6 +122,25 @@ You can read releases logs https://github.com/epezent/implot/releases for more d
#define ImDrawFlags_RoundCornersAll ImDrawCornerFlags_All
#endif
// Visual Studio warnings
#ifdef _MSC_VER
#pragma warning (disable: 4127) // condition expression is constant
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
#endif
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
#endif
// Clang/GCC warnings with -Weverything
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
#endif
// Global plot context
#ifndef GImPlot
ImPlotContext* GImPlot = NULL;
@ -1503,6 +1522,11 @@ void ShowPlotContextMenu(ImPlotPlot& plot) {
// Axis Utils
//-----------------------------------------------------------------------------
static inline void DefaultFormatter(double value, char* buff, int size, void* data) {
char* fmt = (char*)data;
snprintf(buff, size, fmt, value);
}
static inline int AxisPrecision(const ImPlotAxis& axis) {
const double range = axis.Ticks.Size > 1 ? (axis.Ticks.Ticks[1].PlotPos - axis.Ticks.Ticks[0].PlotPos) : axis.Range.Size();
return Precision(range);

View File

@ -42,12 +42,12 @@
#error Must include implot.h before implot_internal.h
#endif
// Support for pre-1.84 versions. ImPool's GetSize() -> GetBufSize()
#if (IMGUI_VERSION_NUM < 18303)
#define GetBufSize GetSize
#endif
//-----------------------------------------------------------------------------
// [SECTION] Constants
//-----------------------------------------------------------------------------
@ -1341,11 +1341,6 @@ IMPLOT_API bool ShowLegendContextMenu(ImPlotLegend& legend, bool visible);
// [SECTION] Tick Utils
//-----------------------------------------------------------------------------
static inline void DefaultFormatter(double value, char* buff, int size, void* data) {
char* fmt = (char*)data;
snprintf(buff, size, fmt, value);
}
// Label a tick with time formatting.
IMPLOT_API void LabelTickTime(ImPlotTick& tick, ImGuiTextBuffer& buffer, const ImPlotTime& t, ImPlotDateTimeFmt fmt);