mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-16 19:11:13 +00:00
gcc build warning #5104
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#5104
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In gcc, when compiling at maximum error and warning levels (-Wall -Wextra -pedantic -Werror), there is a build warning (which is treated as an error for my project), at imgui_impl_glfw.cpp, line 129.
/home/jamesboer/Projects/ImFrame/Source/ImGui/imgui_impl_glfw.cpp: In constructor ‘ImGui_ImplGlfw_Data::ImGui_ImplGlfw_Data()’:
/home/jamesboer/Projects/ImFrame/Source/ImGui/imgui_impl_glfw.cpp:129:60: error: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct ImGui_ImplGlfw_Data’; use assignment or value-initialization instead [-Werror=class-memaccess]
129 | ImGui_ImplGlfw_Data() { memset(this, 0, sizeof(*this)); }
| ^
/home/jamesboer/Projects/ImFrame/Source/ImGui/imgui_impl_glfw.cpp:107:8: note: ‘struct ImGui_ImplGlfw_Data’ declared here
107 | struct ImGui_ImplGlfw_Data
| ^~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/ImFrame.dir/build.make:89: CMakeFiles/ImFrame.dir/Source/ImGui/imgui_impl_glfw.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:288: CMakeFiles/ImFrame.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
gcc does not like zeroing a struct with non trivial data using memset. If you don't wish to initialize individual members, you can get around this warning by casting the this pointer to void*.
ImGui_ImplGlfw_Data() { memset((void*)this, 0, sizeof(*this)); }
Pushed a fix as part of
fd06ed833bThank you!
(PS: I don't think it makes any sense to be compiling third-party code with zealous warnings let alone warnings on error. If you use third-party code you are implicitly trusting what the code does.)
I typically compile 3rd party, ImGui included, with less strict settings, for obvious reasons. In this particular case, I copy those particular files into my own project, and thus they are subject to the more strict compiler settings my own code uses.
You are right, and I guess this is exacerbated by dear imgui’s position on suggesting to do so, I hadn’t thought about that aspect before. Thanks for bringing to light.
Not a problem.
I do appreciate ImGui providing such handy drop-in integration files, as it really makes integration and maintenance a snap. When I previously integrated it into my own game engine using it's own APIs, for which there obviously weren't convenient integration files, it certainly was a lot more work. So I definitely think it's the right approach.
Anyhow, as always, I appreciate the work you do on this great library.