pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
606 stars 91 forks source link

Operator"" _str compilation error #34

Closed Guillaume227 closed 1 year ago

Guillaume227 commented 1 year ago

I am trying to compile my app against hello_imgui checked-out as a submodule on Windows. I am surprised it's complaining out of the box about the following statement in pnm.h : using detail::literals::operator"" _str;

"C:\PROGRA~1\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx86\x64\cl.exe"  /nologo /TP  -DHELLOIMGUI_HAS_OPENGL -DHELLOIMGUI_USE_GLAD -DHELLOIMGUI_USE_GLFW -DHELLOIMGUI_USE_GLFW_OPENGL3 -DIMGUI_IMPL_OPENGL_LOADER_GLAD -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -IC:\...\extern\imlibs\hello_imgui\src\hello_imgui -IC:\...\extern\imlibs\hello_imgui\src\hello_imgui\.. -IC:\...\extern\imlibs\hello_imgui\external\imgui -IC:\...\cmake-build-debug-visual-studio\_deps\glfw-src\include -IC:\...\extern\imlibs\hello_imgui\external\SYSTEM -IC:\...\extern\imlibs\hello_imgui\external\OpenGL_Loaders\glad\include /DWIN32 /D_WINDOWS  /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /W4 /Zc:preprocessor /permissive- -D_CRT_SECURE_NO_WARNINGS -std:c++17 /showIncludes /Foextern\imlibs\hello_imgui\src\hello_imgui\CMakeFiles\hello_imgui.dir\internal\backend_impls\opengl_setup_helper\opengl_screenshot.cpp.obj /Fdextern\imlibs\hello_imgui\src\hello_imgui\CMakeFiles\hello_imgui.dir\hello_imgui.pdb /FS -c C:\...\extern\imlibs\hello_imgui\src\hello_imgui\internal\backend_impls\opengl_setup_helper\opengl_screenshot.cpp
C:\...\extern\imlibs\hello_imgui\src\hello_imgui/internal/pnm.h(1046): warning C4267: 'argument': conversion from 'size_t' to 'const uint8_t', possible loss of data```
C:\...\extern\imlibs\hello_imgui\src\hello_imgui/internal/pnm.h(1076): error C3688: invalid literal suffix '_str'; literal operator or literal operator template 'operator ""_str' not found

I haven't found authoritative info about the proper way to import literal operators but I tried locally replacing the using statements with: using namespace details::literals and that makes the error go away.

  1. could I be hitting a cross platform glitch? Am I missing a compiler flag or something?
  2. c++ 14 has std::literals::string_literals::operator""s - why not use that one instead by the way? Is there a commitment to not exceeding c++11 compat ?
pthom commented 1 year ago

Hi,

Thanks for the report.

I guess that this issue should be reported to the original author of pnm. Could you please report this to him?

Since its license is MIT, we could also edit the file and replace _str by _s , since HelloImGui requires C++17 (but pnm is made for C++11).

However, let's wait for a few days, until we see if the original author answers with a possible patch :-)

pthom commented 1 year ago

In the meantime, I pushed a temporary fix in https://github.com/pthom/hello_imgui/commit/aad56854294d6766f571fdd6188fa46fc56e34ee, as per your suggestion

Guillaume227 commented 1 year ago

Thanks for the prompt reply. I just filed an issue over in the pnm project as you suggested: https://github.com/ToruNiina/pnm/issues/6 I still find it suspicious that I am the first one reporting this on what seems like a basic windows use case. I can't be the first one to have attempted that?

pthom commented 1 year ago

Well, you probably just got an update on your compiler, which is not yet available on github action runners.

I did not get this error yet, although its being compiled on lots of compilers at each push

Guillaume227 commented 1 year ago

Thanks for the temporary fix - I just want to point out there are a number of such statements in that same file and all need replacing for compilation to pass in my case.

pthom commented 1 year ago

Thanks