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

redundant #include of module 'std.depr.string_h' appears within namespace 'ImStb' #4791

Closed
mnesarco opened this issue Dec 8, 2021 · 8 comments

Comments

@mnesarco
Copy link

mnesarco commented Dec 8, 2021

Dear ImGui 1.86 WIP (18502)

sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=202002
define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS
define: linux
define: GNUC=4
define: clang_version=12.0.1
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK

io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3

Version/Branch of Dear ImGui:

Version: Dear ImGui 1.86 WIP (18502)
Branch: docking

Back-end/Renderer/Compiler/OS

io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
Compiler: Clang 12
Operating System: Linux Mint 19.3

My Issue/Question:

I am having a strange compilation error from imstb_textedit.h:387

The error disappears if I comment that line:

#include <string.h>

Screenshots/Video

[build] FAILED: 3rdparty/imgui/CMakeFiles/imgui.dir/Debug/vendor/imgui_widgets.cpp.o 
[build] ccache /usr/bin/c++ -DCMAKE_INTDIR=\"Debug\" -I/home/dev/3rdparty/imgui/src -I/home/dev/3rdparty/imgui/vendor/backends -I/home/dev/3rdparty/imgui/vendor -march=native -Wno-unused-command-line-argument -fuse-ld=lld -stdlib=libc++ -fno-builtin -fmodules -fbuiltin-module-map -Wall -Wextra -Wpedantic -Wmove -Wdangling -g -std=gnu++20 -MD -MT 3rdparty/imgui/CMakeFiles/imgui.dir/Debug/vendor/imgui_widgets.cpp.o -MF 3rdparty/imgui/CMakeFiles/imgui.dir/Debug/vendor/imgui_widgets.cpp.o.d -o 3rdparty/imgui/CMakeFiles/imgui.dir/Debug/vendor/imgui_widgets.cpp.o -c /home/dev/3rdparty/imgui/vendor/imgui_widgets.cpp
[build] In file included from /home/dev/3rdparty/imgui/vendor/imgui_widgets.cpp:3768:
[build] /home/dev/3rdparty/imgui/vendor/imstb_textedit.h:387:1: error: redundant #include of module 'std.depr.string_h' appears within namespace 'ImStb' [-Wmodules-import-nested-redundant]
[build] #include <string.h>
[build] ^
[build] /home/dev/3rdparty/imgui/vendor/imgui_widgets.cpp:3666:1: note: namespace 'ImStb' begins here
[build] namespace ImStb
[build] ^
[build] 1 error generated.

Standalone, minimal, complete and verifiable example:

It is complicated to isolate it, it is part of a big project, but I updated ImGui recently and today I deleted the build and cache dirs and rebuild everything and i get this error.

I am not sure what is happening, maybe someone have seen this before.

@rokups
Copy link
Contributor

rokups commented Dec 8, 2021

Neither STB nor Dear ImGui libraries support modules currently, therefore you should not try to build Dear ImGui with -fmodule. You could build Dear ImGui as a static library not using modules and then export library interface like so:

// imgui.cppm
module;
#include "imgui.h"
export module imgui;

@mnesarco
Copy link
Author

mnesarco commented Dec 8, 2021

Thank you @rokups .

@mnesarco mnesarco closed this as completed Dec 8, 2021
@JohelEGP
Copy link
Contributor

The issue is that the #include happens within namespace ImStb:

imgui/imgui_internal.h

Lines 206 to 208 in f1781c2

#include "imstb_textedit.h"
} // namespace ImStb

#include <string.h>

I'm not compiling Dear ImGui as a module,
but using Clang Modules,
which performs include translation on #include <string.h>.
Can I provide a PR to close and reopen the namespace between the #include?

@ocornut
Copy link
Owner

ocornut commented Jul 27, 2023

Since it seems to only happen here I would define the memmove define the lib is using to avoid the include.

@JohelEGP
Copy link
Contributor

I will leave that to a more brave soul.
I don't know if the uses of memmove in imstb_textedit.h are performance sensitive
and don't feel like attempting to write a version that competes with the one in <string.h>.
For now, I just unwrapped the namespace around the #include in #6653.

@ocornut
Copy link
Owner

ocornut commented Jul 27, 2023

I meant that just specifying “ #define STB_TEXTEDIT_memmove memmove” on our end would completely side-step the problem, since we already have included the header and have access to memmove.

@JohelEGP
Copy link
Contributor

I understand.
I suspected it was already included, given the error message.
I will readjust the PR.

@ocornut
Copy link
Owner

ocornut commented Jul 27, 2023

Your readjustment seems to be doing something else (you removed include from stb_textedit.h)
I'll push a separate commit with the correct solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants