-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing Many Compile Warnings/Errors With Clang #5760
Comments
Thanks for reporting!
There are often reasons making things not "simple". It would have be easier to have a list of actual warning output, or even a PR, because it is unlikely there are all going to be fixed immediately and the line number are already hard to track today. The general policy IHMO is you should not compile third-party code with stringent warnings. You trust the code or you don't, the warnings are meaningless. A few things like warnings on "unused macros" on including a header file are pretty much counter-productive, if not nefarious warnings. It's not our job to support that kind of things and I have issue with conforming or ignoring to some of them (unused-macros in particularly), bowing down to their sheer stupidity enables them to grow while really they shouldn't be used.
It is
I don't know where they are and the line number don't seem to match. I took the liberty to add [] markers in your list to make it checkable and check the things that I believe are fixed now (7 out of 15 fixed by c54230d). |
Apart from those two
and
I don't think it is worth fixing the other. |
# Conflicts: # backends/imgui_impl_dx10.cpp # backends/imgui_impl_dx11.cpp # backends/imgui_impl_dx12.cpp # backends/imgui_impl_dx9.cpp # backends/imgui_impl_glfw.cpp # backends/imgui_impl_opengl2.cpp # backends/imgui_impl_opengl3.cpp # backends/imgui_impl_osx.mm # backends/imgui_impl_sdl.cpp # backends/imgui_impl_vulkan.cpp # backends/imgui_impl_win32.cpp # imgui_internal.h
Hi. Thanks for fixing some of the warnings so far! Addressing issues raised below, in-order:
For 3rd-party code I sortof agree: warnings can indicate a problem upstream, and should be reported to the maintainers. If this doesn't undermine your trust in the package, you may continue to use it. I.e., if the code works, it's not your problem. However, note that ImGui straddles a line between 3rd-party and 1st-party, in that it is written by a 3rd-party, but it is also explicitly encouraged to be
(Emphasis yours.) This gives rise to:
I agree that some warnings are spurious or even antipattern-encouraging and, while one could debate which ones are which, I'm going after a simple, common case here: boss says Regarding Thus, I retract my statement that the casing should be changed as a matter of correctness per-se, but I do think the warning does need to be handled somehow. Perhaps the warning should be ignored for Clang (Is it true that every platform that includes
I can't easily get the exact compile I used, but I think this is complaining about the lines: io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
//[...]
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f); E.g. in the first
SDL_RenderGeometryRaw(bd->SDLRenderer, tex,
xy, (int)sizeof(ImDrawVert),
color, (int)sizeof(ImDrawVert),
uv, (int)sizeof(ImDrawVert),
cmd_list->VtxBuffer.Size - pcmd->VtxOffset,
idx_buffer + pcmd->IdxOffset, pcmd->ElemCount, sizeof(ImDrawIdx)); This doesn't like e.g. adding unsigned |
… + fix additional warnings.
That's not the case for MinGW. I blindly fixed the remaining warning with 8a6911b. |
… + fix additional warnings.
Version/Branch of Dear ImGui:
Version: 72096bf6
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_opengl2.cpp + imgui_impl_opengl3.cpp + imgui_impl_sdl.cpp + imgui_impl_sdlrenderer.cpp
Compiler: Clang 14.0.5
Operating System: Win 10 Pro 21H2
My Issue/Question:
There are various compile warnings / errors with Clang compiled with certain warnings. Some effort has clearly been made in the past to fix or ignore them, but it is now out-of-date, and was never complete. Fortunately, fixing each one is simple, even if there are quite a few. I'll list the ones I ran into here for your convenience:
<GL/gl.h>
. Should be<gl/GL.h>
(at least on my system; because everything is terrible, I know that this varies), or ignore-Wnonportable-system-include-path
.NULL
instead ofnullptr
. In C++, usingNULL
is always wrong;nullptr
is a typesafer drop-in replacement. This should be changed globally. As a temporary workaround, ignore-Wzero-as-null-pointer-constant
.clip_max
. Could improve or ignore-Wimplicit-int-float-conversion
.Wunused-macros
.Wunused-macros
.NULL
instead ofnullptr
. Note that-Wzero-as-null-pointer-constant
was disabled in the ".cpp" file, but not in the header it includes. The right solution is instead usingnullptr
, of course.<Windows.h>
. Lowercase has always been incorrect.-Wcast-function-type
would shut it up, but maybe there's a 'right' way.NULL
instead ofnullptr
.-Wimplicit-int-float-conversion
.NULL
instead ofnullptr
.-Wimplicit-int-float-conversion
.-Wcast-align
.-Wsign-conversion
.The text was updated successfully, but these errors were encountered: