Skip to content
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

MSVC: prevent generating of unwanted dead-code logs #5901

Closed
wants to merge 1 commit into from
Closed

MSVC: prevent generating of unwanted dead-code logs #5901

wants to merge 1 commit into from

Conversation

Teselka
Copy link
Contributor

@Teselka Teselka commented Nov 21, 2022

Hello, i found out that MSVC (v143) generates some dead-code on ImGui::DebugLog calls when IMGUI_DISABLE_DEBUG_TOOLS is defined (possibly because it doesn't optimize va_args).

This PR will fix that problem.

@ocornut
Copy link
Owner

ocornut commented Nov 23, 2022

Hello,
Could you clarify what is emitted by MSVC and how to reproduce it? I can't seem to repro this with VS 2022 and IMGUI_DISABLE_DEBUG_TOOLS`.
Are they warnings, if so, can you paste them?

@Teselka
Copy link
Contributor Author

Teselka commented Nov 25, 2022

Yea, MSVC emits unused calls to that function, it leaves unused debug strings. You can check it by executing the following command in the build directory (for me it's x64 release directx9 example)

findstr /C:"[popup] OpenPopup" "example_win32_directx9.exe"
Without my fix it will show output

ocornut pushed a commit that referenced this pull request Nov 28, 2022
…fined. (#5901)

+ needed to rework clipper code to avoid "The 'then' statement is equivalent to the 'else' statement." PVS Studio warning.
@ocornut
Copy link
Owner

ocornut commented Nov 28, 2022

Ah, I understand better what you meant.

Reworked and pushed as 969af7c
I have choosen to only change the initial macro so that's less duplicate in the code.
Enabling this and testing with IMGUI_DISABLE_DEBUG_TOOLS triggered a warning from PVS-Studio which I have also fixed in the comment.

Thank you!

@ocornut ocornut closed this Nov 28, 2022
ocornut pushed a commit that referenced this pull request Jan 2, 2023
…5978)

Fixes MSVC warning C4390 when /W3 is specified. Reworked from original PR: (void)0 provides better codegen by do-while.
Similar to #5901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants