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

Doesn't compile on C++03 because of delegated ctor #97

Closed
eliasdaler opened this issue Jul 26, 2019 · 6 comments
Closed

Doesn't compile on C++03 because of delegated ctor #97

eliasdaler opened this issue Jul 26, 2019 · 6 comments
Labels

Comments

@eliasdaler
Copy link
Contributor

Discovered in microsoft/vcpkg#7429

    ImVec4(const sf::Color & c)                                         \
        : ImVec4(c.r / 255.f, c.g / 255.f, c.b / 255.f, c.a / 255.f) {  \
    }                                                                   \

Delegated ctor is a C++11 feature, so we shouldn't use it. Also funny how no one noticed it for such a long time - guess very-very few people use C++03 now. ¯_(ツ)_/¯

@eliasdaler eliasdaler added the bug label Jul 26, 2019
@scemino
Copy link

scemino commented Sep 27, 2019

When I build your project, I have this error:

In file included from /Users/scemino/imgui-sfml/imgui-SFML.cpp:2:
/Users/scemino/imgui/imgui.h:198:5: error: delegating constructors are permitted only in C++11
    IM_VEC4_CLASS_EXTRA     // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between you...
    ^~~~~~~~~~~~~~~~~~~
/Users/scemino/imgui-sfml/imconfig-SFML.h:22:11: note: expanded from macro 'IM_VEC4_CLASS_EXTRA'
        : ImVec4(c.r / 255.f, c.g / 255.f, c.b / 255.f, c.a / 255.f) {  \
          ^~~~~~

Do you have a workaround or a fix for this ?
I build your project on MacOS 10.14.6 with clang 9.1.0.
Tell me if you need more info.
Thank you.

@scemino
Copy link

scemino commented Sep 27, 2019

OK I found a workaround I added this line in CMakeLists.txt:
set(CMAKE_CXX_STANDARD 11)
after
cmake_minimum_required(VERSION 3.1)
and now it builds 👍

@eliasdaler
Copy link
Contributor Author

Hey, can you please check this on C++03 on latest master?
I've tried to fix it (but yeah, I'd recommend on staying on C++11, or better yet on C++17!)

@eliasdaler eliasdaler reopened this Sep 27, 2019
@scemino
Copy link

scemino commented Sep 27, 2019

Sorry now I have this, I know it has no link with this issue but...

$ cmake . -DIMGUI_DIR=../imgui -DSFML_DIR=/Library/Frameworks/SFML.framework/Versions/2.5.1 -DBUILD_SHARED_LIBS=ON
-- Found SFML 2.5.1 in /Library/Frameworks/SFML.framework/Resources/CMake
-- Found ImGui v1.73 in /usr/local/include
-- Configuring done
CMake Error at CMakeLists.txt:76 (add_library):
  Cannot find source file:

    /usr/local/include/imgui.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at CMakeLists.txt:76 (add_library):
  No SOURCES given to target: ImGui-SFML


CMake Generate step failed.  Build files cannot be regenerated correctly.

Earlier I had this:

cmake . -DIMGUI_DIR=../imgui -DSFML_DIR=/Library/Frameworks/SFML.framework/Versions/2.5.1 -DBUILD_SHARED_LIBS
=ON
-- Found SFML 2.5.1 in /Library/Frameworks/SFML.framework/Resources/CMake
-- Found ImGui v1.73 in /Users/scemino/imgui
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework   
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/scemino/imgui-sfml

I presume the difference comes from

cmake --build . --target install

@scemino
Copy link

scemino commented Sep 27, 2019

OK I had to remove imgui* files from /usr/local/include and now it builds.
Your commit fixed this issue.

eliasdaler added a commit that referenced this issue Sep 27, 2019
Spotted in #97 - we only want to search in IMGUI_SEARCH_PATH, otherwise "IMGUI_DIR" won't work correctly.
@eliasdaler
Copy link
Contributor Author

Fixed in the latest commit. The problem was that by installing ImGui-SFML, you installed imgui.h in /usr/local/include and CMake tried to use /usr/local as a search path in FindImGui.cmake, which is something I don't want to have. So, thanks twice!

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

No branches or pull requests

2 participants