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

Closed
opened 2021-12-08 03:21:28 +00:00 by mnesarco · 8 comments
mnesarco commented 2021-12-08 03:21:28 +00:00 (Migrated from github.com)

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: ocornut/imgui@fc198fe1db/imstb_textedit.h (L387)

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.

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: https://github.com/ocornut/imgui/blob/fc198fe1dbae2e045b7fb31d53466a54f5368414/imstb_textedit.h#L387 **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 commented 2021-12-08 07:30:33 +00:00 (Migrated from github.com)

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;
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: ```cpp // imgui.cppm module; #include "imgui.h" export module imgui; ```
mnesarco commented 2021-12-08 14:32:14 +00:00 (Migrated from github.com)

Thank you @rokups .

Thank you @rokups .
JohelEGP commented 2023-07-26 22:44:03 +00:00 (Migrated from github.com)

The issue is that the #include happens within namespace ImStb:
ocornut/imgui@f1781c20a3/imgui_internal.h (L206-L208)
ocornut/imgui@f1781c20a3/imstb_textedit.h (L390)
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?

The issue is that the `#include` happens within namespace `ImStb`: https://github.com/ocornut/imgui/blob/f1781c20a300bdb7366d8a4f32a8cb6d891e353d/imgui_internal.h#L206-L208 https://github.com/ocornut/imgui/blob/f1781c20a300bdb7366d8a4f32a8cb6d891e353d/imstb_textedit.h#L390 I'm not compiling Dear ImGui as a module, but using [Clang Modules](https://clang.llvm.org/docs/Modules.html), which performs [include translation](https://clang.llvm.org/docs/Modules.html#includes-as-imports) on `#include <string.h>`. Can I provide a PR to close and reopen the namespace between the `#include`?
ocornut commented 2023-07-27 07:36:24 +00:00 (Migrated from github.com)

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

Since it seems to only happen here I would define the memmove define the lib is using to avoid the include.
JohelEGP commented 2023-07-27 11:40:56 +00:00 (Migrated from github.com)

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.

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 commented 2023-07-27 14:00:24 +00:00 (Migrated from github.com)

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.

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 commented 2023-07-27 14:13:00 +00:00 (Migrated from github.com)

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

I understand. I suspected it was already included, given the error message. I will readjust the PR.
ocornut commented 2023-07-27 17:38:33 +00:00 (Migrated from github.com)

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.

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 in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#4791
No description provided.