Skip to content

Fix char types#104

Open
rsxrwscjpzdzwpxaujrr wants to merge 1 commit intoTankOs:masterfrom
rsxrwscjpzdzwpxaujrr:fix-chartype
Open

Fix char types#104
rsxrwscjpzdzwpxaujrr wants to merge 1 commit intoTankOs:masterfrom
rsxrwscjpzdzwpxaujrr:fix-chartype

Conversation

@rsxrwscjpzdzwpxaujrr
Copy link
Copy Markdown

On my machine, I'm getting this error while trying to build:

Details
$ cmake ..
-- The CXX compiler identification is GNU 15.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: /usr/lib/libOpenGL.so
-- Found SFML 3.1.0 in /usr/lib/cmake/SFML
-- Found X11: /usr/include
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Configuring done (1.7s)
-- Generating done (0.1s)
-- Build files have been written to: /home/rsxrw/projects/SFGUI/build
$ make -j2
[  1%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Alignment.cpp.o
[  2%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Adjustment.cpp.o
[  2%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Bin.cpp.o
[  3%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Box.cpp.o
[  4%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Button.cpp.o
[  5%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Canvas.cpp.o
[  6%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/CheckButton.cpp.o
[  6%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/ComboBox.cpp.o
[  7%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Container.cpp.o
/home/rsxrw/projects/SFGUI/src/SFGUI/ComboBox.cpp: In member function ‘virtual void sfg::ComboBox::HandleMouseMoveEvent(int, int)’:
/home/rsxrw/projects/SFGUI/src/SFGUI/ComboBox.cpp:243:23: warning: conversion from ‘int’ to ‘float’ may change value [-Wconversion]
  243 |                 if( ( x > GetAllocation().position.x ) && ( x < GetAllocation().position.x + GetAllocation().size.x ) ) {
      |                       ^
/home/rsxrw/projects/SFGUI/src/SFGUI/ComboBox.cpp:243:61: warning: conversion from ‘int’ to ‘float’ may change value [-Wconversion]
  243 |                 if( ( x > GetAllocation().position.x ) && ( x < GetAllocation().position.x + GetAllocation().size.x ) ) {
      |                                                             ^
[  8%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Context.cpp.o
[  9%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/DejaVuSansFont.cpp.o
[  9%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Desktop.cpp.o
[ 10%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Engine.cpp.o
/home/rsxrw/projects/SFGUI/src/SFGUI/Engine.cpp: In member function ‘sf::Vector2f sfg::Engine::GetTextStringMetrics(const std::u32string&, const sf::Font&, unsigned int) const’:
/home/rsxrw/projects/SFGUI/src/SFGUI/Engine.cpp:140:65: error: call of overloaded ‘getKerning(uint32_t&, const char32_t&, unsigned int&)’ is ambiguous
  140 |                 metrics.x += static_cast<float>( font.getKerning( previous_character, current_character, font_size ) );
      |                                                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/rsxrw/projects/SFGUI/src/SFGUI/Engine.cpp:140:65: note: there are 2 candidates
In file included from /home/rsxrw/projects/SFGUI/src/SFGUI/Engine.cpp:7:
/usr/include/SFML/Graphics/Font.hpp:302:111: note: candidate 1: ‘float sf::Font::getKerning(uint32_t, uint32_t, unsigned int, bool) const’
  302 |     [[deprecated("Use the getKerning(char32_t, char32_t, unsigned int, bool) overload")]] [[nodiscard]] float getKerning(
      |                                                                                                               ^~~~~~~~~~
/usr/include/SFML/Graphics/Font.hpp:325:25: note: candidate 2: ‘float sf::Font::getKerning(char32_t, char32_t, unsigned int, bool) const’
  325 |     [[nodiscard]] float getKerning(char32_t first, char32_t second, unsigned int characterSize, bool bold = false) const;
      |                         ^~~~~~~~~~
/home/rsxrw/projects/SFGUI/src/SFGUI/Engine.cpp: In member function ‘sf::Vector2f sfg::Engine::GetTextStringMetrics(const sf::String&, const sf::Font&, unsigned int) const’:
/home/rsxrw/projects/SFGUI/src/SFGUI/Engine.cpp:207:89: error: call of overloaded ‘getKerning(uint32_t&, const char32_t&, unsigned int&)’ is ambiguous
  207 |                                         metrics.x += static_cast<float>( font.getKerning( previous_character, current_character, font_size ) );
      |                                                                          ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/rsxrw/projects/SFGUI/src/SFGUI/Engine.cpp:207:89: note: there are 2 candidates
/usr/include/SFML/Graphics/Font.hpp:302:111: note: candidate 1: ‘float sf::Font::getKerning(uint32_t, uint32_t, unsigned int, bool) const’
  302 |     [[deprecated("Use the getKerning(char32_t, char32_t, unsigned int, bool) overload")]] [[nodiscard]] float getKerning(
      |                                                                                                               ^~~~~~~~~~
/usr/include/SFML/Graphics/Font.hpp:325:25: note: candidate 2: ‘float sf::Font::getKerning(char32_t, char32_t, unsigned int, bool) const’
  325 |     [[nodiscard]] float getKerning(char32_t first, char32_t second, unsigned int characterSize, bool bold = false) const;
      |                         ^~~~~~~~~~
[ 11%] Building CXX object CMakeFiles/SFGUI.dir/src/SFGUI/Engines/BREW.cpp.o
make[2]: *** [CMakeFiles/SFGUI.dir/build.make:247: CMakeFiles/SFGUI.dir/src/SFGUI/Engine.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:178: CMakeFiles/SFGUI.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

This simple fix fixes the problem. It's safe, as our current_character is also already char32_t, because we're getting the characters from an std::u32string, which is defined as std::basic_string<char32_t>.

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.

1 participant