Estou tentando usar o Clock
from SFML/System.hpp
, mas assim que incluo #include <SFML/System.hpp>
no meu cabeçalho e chamo make
no terminal, recebo o erro mostrado abaixo. Se eu remover essa linha, não há mais erro. Isso nunca foi o caso antes de hoje. Tentei vários casos, mas sem ajuda.
Tenho os seguintes cabeçalhos:
#include <string>
#include <iostream>
#include <fstream>
#include <SFML/System.hpp>
#include "EDistance.hpp"
ERRO:
g++ --std=c++17 -Wall -Werror -pedantic -g -c main.cpp -I/opt/homebrew/Cellar/boost/1.87.0_1/include/ -I/opt/homebrew/Cellar/sfml@2/2.6.2_1/include/
In file included from main.cpp:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string:821:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned int>'
821 | static_assert(is_same<_CharT, typename traits_type::char_type>::value,
| ^
/opt/homebrew/Cellar/sfml@2/2.6.2_1/include/SFML/System/String.hpp:52:18: note: in instantiation of template class 'std::basic_string<unsigned int>' requested here
52 | typedef std::basic_string<Uint32>::iterator Iterator; //!< Iterator type
| ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
| ^
1 error generated.
make: *** [main.o] Error 1
std::basic_string
, e em particularstd::char_traits
, não é destinado a ser usado com tipos inteiros, apenas tipos de caracteres. É por isso que o compilador está reclamando sobrestd::char_traits<unsigned int>
ser indefinido.O tipo do SFML
sf::String
é uma string UTF-32, então eles deveriam usarchar32_t
em vez deUInt32
.char32_t
foi adicionado no C++11 especificamente para oferecer suporte a UTF-32.Você parece estar usando uma versão mais antiga do SFML (2.6.2), onde
Sf::String
usesstd::basic_string<UInt32>
. No SFML 3.0.0, eles mudaramSf::String
para usestd::u32string
(akastd::basic_string<char32_t>
). Você deve considerar atualizar sua cópia do SFML.