Skip to content

Conversation

ypujante
Copy link
Contributor

@ypujante ypujante commented Sep 7, 2024

Hi @ocornut

This is the follow up that you requested in PR #7915

This PR contains 2 independent commits for you to cherry pick:


(1) this is the one that moves the code to use the macOS behavior to the ImGui_ImplGlfw_Init as you suggested. I also added comments and as I mentioned in the other PR, I created a comprehensive documentation to clearly explain the differences between the 2 implementations.

Note that this commit also includes a change to the CMakeLists.txt file as without this change you get a nasty warning and the check #if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 >= 34020240817 does not work


(2) This second commit corresponds to the commit (1) in the other PR

changed CI test to also test the CMakeLists build for example_glfw_wgpu and Emscripten: this tests the path when emscripten-glfw is used.

I still think that this is a worthwhile addition otherwise the piece of code I added in (1) is never tested in CI run...


I paid ultra close attention to code style. I hope I got it right this time around ;)

@ypujante
Copy link
Contributor Author

ypujante commented Sep 7, 2024

The first run failed because of the syntax:

#if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 >= 3'4'0'20240817
../../backends/imgui_impl_glfw.cpp:649:43: error: token is not a valid binary operator in a preprocessor subexpression
#if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 >= 3'4'0'20240817
                                         ~^
../../backends/imgui_impl_glfw.cpp:649:47: warning: missing terminating ' character [-Winvalid-pp-token]
#if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 >= 3'4'0'20240817

This error is due to compiling with c++11 which does not support this syntax: this syntax was introduced 10 years ago with c++14...

I fixed it by removing the quotes and now CI is happy

@ocornut
Copy link
Owner

ocornut commented Sep 12, 2024

On the CI commit:

I still think that this is a worthwhile addition otherwise the piece of code I added in (1) is never tested in CI run...

I agree but the comment doesn't seem to mention this:
"Build example_glfw_wgpu with Emscripten/Makefile" vs "Build example_glfw_wgpu with Emscripten/CMake"
If "build-essential" is required please add a comment to explain why (in file or commit) so we have a trace of it.

Thanks for writing and linking to that docs/Usage.md docs in your repository, this is helpful!

ocornut pushed a commit that referenced this pull request Sep 12, 2024
@ocornut
Copy link
Owner

ocornut commented Sep 12, 2024

I have merged the OSX commit as ac2ad79 but not the CI commit yet. (You can freely force-push edits to same branchs and i'll merge the other commits), or since I am only expecting extra comments on the CI one you can write them here and I'll append them myself.

This error is due to compiling with c++11 which does not support this syntax: this syntax was introduced 10 years ago with c++14...

I have appended to your commit the same change to the other #if in the same file.
For now we generally stick to C++11 to maximize compatibility, as some projects and platforms are not supporting newer standards. Although for platform-specific code (and Emscripten is platform specific) we can rely on newer things if they are needed and useful. But if it's not needed better not raise a requirement needlessly.

I am also surprised that #if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 >= 34020240817 is not warning if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 is not defined. I don't know if it is because the code is not compiled will all warnings or if that became a silent thing in recentish versions of CPP proprocessor, or if I am misremembering?

I paid ultra close attention to code style. I hope I got it right this time around ;)

Thanks! I always tend to make small tweaks. If you are super curious you may compare my merged commit to yours (personally I use Git Fork I can easily see both and compare) but nothing crucial, don't sweat it.

@ypujante
Copy link
Contributor Author

Thank you @ocornut

I have force pushed a new commit with added comments as you suggested.

@ypujante
Copy link
Contributor Author

I am also surprised that #if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 >= 34020240817 is not warning if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 is not defined. I don't know if it is because the code is not compiled will all warnings or if that became a silent thing in recentish versions of CPP proprocessor, or if I am misremembering?

I suppose I am not an expert in CPP preprocessor behavior so maybe it might cause problems with some compilers?

Since we know for a fact that it works with the Emscripten compiler, maybe it would be safer to also protect this block? (other blocks are protected)

// ... Line 649 ...
#ifdef __EMSCRIPTEN__
#if EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3 >= 34020240817
...
#endif
#endif

ocornut pushed a commit that referenced this pull request Sep 12, 2024
+ Backends: GLFW: minor preemptive fix.
@ocornut
Copy link
Owner

ocornut commented Sep 12, 2024

Merged both changes! Thank you!

@ocornut ocornut closed this Sep 12, 2024
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 this pull request may close these issues.

2 participants