From 947cf3434f1e17354f90e8b3ffed05958ebd483e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20P=C3=B6chtrager?= Date: Sat, 8 Aug 2015 19:29:11 +0200 Subject: [PATCH 1/2] Added printf attribute to printf like text formatting functions --- examples/opengl3_example/Makefile | 4 +-- examples/opengl_example/Makefile | 4 +-- imgui.cpp | 5 ++-- imgui.h | 44 ++++++++++++++++++------------- imgui_demo.cpp | 8 +++--- imgui_internal.h | 2 +- 6 files changed, 37 insertions(+), 30 deletions(-) diff --git a/examples/opengl3_example/Makefile b/examples/opengl3_example/Makefile index ec8c57f2..748fd4dc 100644 --- a/examples/opengl3_example/Makefile +++ b/examples/opengl3_example/Makefile @@ -22,7 +22,7 @@ ifeq ($(UNAME_S), Linux) #LINUX LIBS = `pkg-config --static --libs glfw3` CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3` - CXXFLAGS += -Wall + CXXFLAGS += -Wall -Wformat CFLAGS = $(CXXFLAGS) endif @@ -33,7 +33,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE LIBS += -lglfw3 CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include - CXXFLAGS += -Wall + CXXFLAGS += -Wall -Wformat # CXXFLAGS += -D__APPLE__ CFLAGS = $(CXXFLAGS) endif diff --git a/examples/opengl_example/Makefile b/examples/opengl_example/Makefile index 570fa1ac..d05a0f90 100644 --- a/examples/opengl_example/Makefile +++ b/examples/opengl_example/Makefile @@ -21,7 +21,7 @@ ifeq ($(UNAME_S), Linux) #LINUX LIBS = `pkg-config --static --libs glfw3` CXXFLAGS = -I../../ `pkg-config --cflags glfw3` - CXXFLAGS += -Wall + CXXFLAGS += -Wall -Wformat CFLAGS = $(CXXFLAGS) endif @@ -32,7 +32,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE LIBS += -lglfw3 CXXFLAGS = -I../../ -I/usr/local/include - CXXFLAGS += -Wall + CXXFLAGS += -Wall -Wformat # CXXFLAGS += -D__APPLE__ CFLAGS = $(CXXFLAGS) endif diff --git a/imgui.cpp b/imgui.cpp index d9b0cf25..8fe57575 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -458,7 +458,6 @@ - input: rework IO to be able to pass actual events to fix temporal aliasing issues. - input: support track pad style scrolling & slider edit. - memory: add a way to discard allocs of unused/transient windows. with the current architecture new windows (including popup, opened combos, listbox) perform at least 3 allocs. - - misc: mark printf compiler attributes on relevant functions - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL) - misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? - style editor: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space? @@ -2071,7 +2070,7 @@ static void LoadSettings() if (line_start[0] == '[' && line_end > line_start && line_end[-1] == ']') { char name[64]; - ImFormatString(name, IM_ARRAYSIZE(name), "%.*s", line_end-line_start-2, line_start+1); + ImFormatString(name, IM_ARRAYSIZE(name), "%.*s", (int)(line_end-line_start-2), line_start+1); settings = FindWindowSettings(name); if (!settings) settings = AddWindowSettings(name); @@ -8881,7 +8880,7 @@ void ImGui::ShowMetricsWindow(bool* opened) NodeDrawList(window->DrawList, "DrawList"); if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow"); if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows"); - ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * sizeof(ImGuiStorage::Pair)); + ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair)); ImGui::TreePop(); } }; diff --git a/imgui.h b/imgui.h index f958c85b..1088fedd 100644 --- a/imgui.h +++ b/imgui.h @@ -25,6 +25,14 @@ #define IM_ASSERT(_EXPR) assert(_EXPR) #endif +#ifdef __GNUC__ +// warning : format string is not a string literal (potentially insecure) +#pragma GCC diagnostic ignored "-Wformat-security" +#define IM_PRINTFARGS(fmt, args) __attribute__((format(printf, fmt, args))) +#else +#define IM_PRINTFARGS(fmt, args) +#endif + // Define attributes of all API symbols declarations, e.g. for DLL under Windows. #ifndef IMGUI_API #define IMGUI_API @@ -213,19 +221,19 @@ namespace ImGui IMGUI_API ImGuiID GetID(const void* ptr_id); // Widgets - IMGUI_API void Text(const char* fmt, ...); + IMGUI_API void Text(const char* fmt, ...) IM_PRINTFARGS(1, 2); IMGUI_API void TextV(const char* fmt, va_list args); - IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); + IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_PRINTFARGS(2, 3); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args); - IMGUI_API void TextDisabled(const char* fmt, ...); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); + IMGUI_API void TextDisabled(const char* fmt, ...) IM_PRINTFARGS(1, 2); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); IMGUI_API void TextDisabledV(const char* fmt, va_list args); - IMGUI_API void TextWrapped(const char* fmt, ...); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). + IMGUI_API void TextWrapped(const char* fmt, ...) IM_PRINTFARGS(1, 2); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). IMGUI_API void TextWrappedV(const char* fmt, va_list args); - IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text - IMGUI_API void LabelText(const char* label, const char* fmt, ...); // display text+label aligned the same way as value+label widgets + IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text + IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_PRINTFARGS(2, 3); // display text+label aligned the same way as value+label widgets IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args); IMGUI_API void Bullet(); - IMGUI_API void BulletText(const char* fmt, ...); + IMGUI_API void BulletText(const char* fmt, ...) IM_PRINTFARGS(1, 2); IMGUI_API void BulletTextV(const char* fmt, va_list args); IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); IMGUI_API bool SmallButton(const char* label); @@ -287,15 +295,15 @@ namespace ImGui IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f"); // Widgets: Trees - IMGUI_API bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop - IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...); // " - IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...); // " - IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // " - IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // " - IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose - IMGUI_API void TreePush(const void* ptr_id = NULL); // " + IMGUI_API bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop + IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_PRINTFARGS(2, 3); // " + IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_PRINTFARGS(2, 3); // " + IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // " + IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // " + IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose + IMGUI_API void TreePush(const void* ptr_id = NULL); // " IMGUI_API void TreePop(); - IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node to be opened. + IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node to be opened. // Widgets: Selectable / Lists IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height @@ -315,7 +323,7 @@ namespace ImGui IMGUI_API void Color(const char* prefix, unsigned int v); // Tooltip - IMGUI_API void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins + IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1, 2); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins IMGUI_API void SetTooltipV(const char* fmt, va_list args); IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text IMGUI_API void EndTooltip(); @@ -346,7 +354,7 @@ namespace ImGui IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard IMGUI_API void LogFinish(); // stop logging (close file, etc.) IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard - IMGUI_API void LogText(const char* fmt, ...); // pass text data straight to log (without being displayed) + IMGUI_API void LogText(const char* fmt, ...) IM_PRINTFARGS(1, 2); // pass text data straight to log (without being displayed) // Utilities IMGUI_API bool IsItemHovered(); // was the last item hovered by mouse? @@ -861,7 +869,7 @@ struct ImGuiTextBuffer int size() const { return Buf.Size-1; } bool empty() { return size() >= 1; } void clear() { Buf.clear(); Buf.push_back(0); } - IMGUI_API void append(const char* fmt, ...); + IMGUI_API void append(const char* fmt, ...) IM_PRINTFARGS(2, 3); IMGUI_API void appendv(const char* fmt, va_list args); }; diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 255c4638..e442f577 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1121,7 +1121,7 @@ void ImGui::ShowTestWindow(bool* opened) selected = i; ImGui::NextColumn(); ImGui::Text(names[i]); ImGui::NextColumn(); - ImGui::Text(paths[i]); ImGui::NextColumn(); + ImGui::Text(paths[i]); ImGui::NextColumn(); ImGui::Text("...."); ImGui::NextColumn(); } ImGui::Columns(1); @@ -1424,7 +1424,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref) const ImVec4& col = style.Colors[i]; const char* name = ImGui::GetStyleColName(i); if (!output_only_modified || memcmp(&col, (ref ? &ref->Colors[i] : &def.Colors[i]), sizeof(ImVec4)) != 0) - ImGui::LogText("style.Colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 22 - strlen(name), "", col.x, col.y, col.z, col.w); + ImGui::LogText("style.Colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 22 - (int)strlen(name), "", col.x, col.y, col.z, col.w); } ImGui::LogFinish(); } @@ -1702,7 +1702,7 @@ struct ExampleAppConsole ScrollToBottom = true; } - void AddLog(const char* fmt, ...) + void AddLog(const char* fmt, ...) IM_PRINTFARGS(2, 3) { char buf[1024]; va_list args; @@ -1862,7 +1862,7 @@ struct ExampleAppConsole if (candidates.Size == 0) { // No match - AddLog("No match for \"%.*s\"!\n", word_end-word_start, word_start); + AddLog("No match for \"%.*s\"!\n", (int)(word_end-word_start), word_start); } else if (candidates.Size == 1) { diff --git a/imgui_internal.h b/imgui_internal.h index dc5714f0..a68663a4 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -90,7 +90,7 @@ char* ImStrdup(const char* str); int ImStrlenW(const ImWchar* str); const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line const char* ImStristr(const char* haystack, const char* needle, const char* needle_end); -int ImFormatString(char* buf, int buf_size, const char* fmt, ...); +int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_PRINTFARGS(3, 4); int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args); // Helpers: Math From aa3c26fd30e1c13a1af8cc00bf97feb0c63034da Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 8 Aug 2015 12:26:22 -0600 Subject: [PATCH 2/2] IM_PRINTFARGS takes one argument. Moved pragma outside of .h (#295) --- imgui.h | 50 +++++++++++++++++++++++------------------------- imgui_demo.cpp | 3 ++- imgui_internal.h | 2 +- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/imgui.h b/imgui.h index f65b17f1..7e3bf64b 100644 --- a/imgui.h +++ b/imgui.h @@ -25,19 +25,17 @@ #define IM_ASSERT(_EXPR) assert(_EXPR) #endif -#ifdef __GNUC__ -// warning : format string is not a string literal (potentially insecure) -#pragma GCC diagnostic ignored "-Wformat-security" -#define IM_PRINTFARGS(fmt, args) __attribute__((format(printf, fmt, args))) -#else -#define IM_PRINTFARGS(fmt, args) -#endif - // Define attributes of all API symbols declarations, e.g. for DLL under Windows. #ifndef IMGUI_API #define IMGUI_API #endif +#if defined(__clang__) || defined(__GNUC__) +#define IM_PRINTFARGS(FMT) __attribute__((format(printf, FMT, (FMT+1)))) +#else +#define IM_PRINTFARGS(FMT) +#endif + // Forward declarations struct ImDrawCmd; struct ImDrawList; @@ -221,19 +219,19 @@ namespace ImGui IMGUI_API ImGuiID GetID(const void* ptr_id); // Widgets - IMGUI_API void Text(const char* fmt, ...) IM_PRINTFARGS(1, 2); + IMGUI_API void Text(const char* fmt, ...) IM_PRINTFARGS(1); IMGUI_API void TextV(const char* fmt, va_list args); - IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_PRINTFARGS(2, 3); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); + IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_PRINTFARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args); - IMGUI_API void TextDisabled(const char* fmt, ...) IM_PRINTFARGS(1, 2); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); + IMGUI_API void TextDisabled(const char* fmt, ...) IM_PRINTFARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); IMGUI_API void TextDisabledV(const char* fmt, va_list args); - IMGUI_API void TextWrapped(const char* fmt, ...) IM_PRINTFARGS(1, 2); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). + IMGUI_API void TextWrapped(const char* fmt, ...) IM_PRINTFARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). IMGUI_API void TextWrappedV(const char* fmt, va_list args); - IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text - IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_PRINTFARGS(2, 3); // display text+label aligned the same way as value+label widgets + IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text + IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_PRINTFARGS(2); // display text+label aligned the same way as value+label widgets IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args); IMGUI_API void Bullet(); - IMGUI_API void BulletText(const char* fmt, ...) IM_PRINTFARGS(1, 2); + IMGUI_API void BulletText(const char* fmt, ...) IM_PRINTFARGS(1); IMGUI_API void BulletTextV(const char* fmt, va_list args); IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); IMGUI_API bool SmallButton(const char* label); @@ -295,15 +293,15 @@ namespace ImGui IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f"); // Widgets: Trees - IMGUI_API bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop - IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_PRINTFARGS(2, 3); // " - IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_PRINTFARGS(2, 3); // " - IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // " - IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // " - IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose - IMGUI_API void TreePush(const void* ptr_id = NULL); // " + IMGUI_API bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop + IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_PRINTFARGS(2); // " + IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_PRINTFARGS(2); // " + IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // " + IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // " + IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose + IMGUI_API void TreePush(const void* ptr_id = NULL); // " IMGUI_API void TreePop(); - IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node to be opened. + IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node to be opened. // Widgets: Selectable / Lists IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height @@ -323,7 +321,7 @@ namespace ImGui IMGUI_API void Color(const char* prefix, unsigned int v); // Tooltip - IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1, 2); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins + IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins IMGUI_API void SetTooltipV(const char* fmt, va_list args); IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text IMGUI_API void EndTooltip(); @@ -354,7 +352,7 @@ namespace ImGui IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard IMGUI_API void LogFinish(); // stop logging (close file, etc.) IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard - IMGUI_API void LogText(const char* fmt, ...) IM_PRINTFARGS(1, 2); // pass text data straight to log (without being displayed) + IMGUI_API void LogText(const char* fmt, ...) IM_PRINTFARGS(1); // pass text data straight to log (without being displayed) // Utilities IMGUI_API bool IsItemHovered(); // was the last item hovered by mouse? @@ -869,7 +867,7 @@ struct ImGuiTextBuffer int size() const { return Buf.Size-1; } bool empty() { return size() >= 1; } void clear() { Buf.clear(); Buf.push_back(0); } - IMGUI_API void append(const char* fmt, ...) IM_PRINTFARGS(2, 3); + IMGUI_API void append(const char* fmt, ...) IM_PRINTFARGS(2); IMGUI_API void appendv(const char* fmt, va_list args); }; diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 9799fde5..94600323 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -25,6 +25,7 @@ #endif #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size +#pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure) #endif // Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n. @@ -1702,7 +1703,7 @@ struct ExampleAppConsole ScrollToBottom = true; } - void AddLog(const char* fmt, ...) IM_PRINTFARGS(2, 3) + void AddLog(const char* fmt, ...) IM_PRINTFARGS(2) { char buf[1024]; va_list args; diff --git a/imgui_internal.h b/imgui_internal.h index 2cebd074..3df23dad 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -90,7 +90,7 @@ char* ImStrdup(const char* str); int ImStrlenW(const ImWchar* str); const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line const char* ImStristr(const char* haystack, const char* needle, const char* needle_end); -int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_PRINTFARGS(3, 4); +int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_PRINTFARGS(3); int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args); // Helpers: Math