-
It happened at SFML v2.4.2
I am not sure it is belong to SFML or not.
// It's only crash on Visual Studio 2015
sf::Window(sf::VideoMode(800,600),sf::String(std::wstring(L"title")));
// It looks fine on any compiler
sf::Window(sf::VideoMode(800,600),sf::String(std::wstring(L"title").c_str()));
-
Have you tried it outside of the window constructor?
-
Have you tried it outside of the window constructor?
I was tried.
Nothing wrong with sf::Window constructor.
It's all about sf::String constructor.
Maybe something wrong with "std::basic_string" on Visual Studio 2015.
-
So this doesn't work for you?:
#include <string>
#include <SFML/System/String.hpp>
int main()
{
std::string s{ "string" };
sf::String sfs(s);
std::wstring w{ L"wide string" };
sf::String sfw(w);
}
-
What's the crash? What's the call stack? Do you mix debug and release version?
You don't really need to convert L"" to std::wstring first.
-
So this doesn't work for you?:
#include <string>
#include <SFML/System/String.hpp>
int main()
{
std::string s{ "string" };
sf::String sfs(s);
std::wstring w{ L"wide string" };
sf::String sfw(w);
}
I just try it.
"sf::String" really couldn't take "std::wstring" on Visual Studio 2015.
-
What's the crash? What's the call stack? Do you mix debug and release version?
You don't really need to convert L"" to std::wstring first.
I set "release" to CMAKE_BUILD_TYPE.
It should always crash if I mix debug and release version.
My SFML library is download from the official website.(Not compile it by myself)
-----------Error message box give me this-----------
Debug error!
Program:
D:\...\my_project.exe
abort() has been called
(Press Retry to debug the application)
-----------------------------------------------------------
// It crash too
std::string str("just a UTF-8 string");
return sf::String::fromUtf8( str.begin(), str.end() );
-
Yes it does work or yes it doesn't?
Are you saying that it works if a temporary is created first as in my example but not otherwise?
How about this:
#include <string>
#include <SFML/System/String.hpp>
int main()
{
sf::String a(std::wstring(L"wide string"));
sf::String b(L"wide string");
}
Any problems here?
-
Thank you Hapax and eXpl0it3r.
And eXpl0it3r probably right.
Maybe CMAKE_BUILD_TYPE doesn't work on Visual Studio.
I usually run Visual Studio Solution in command line.
So I must be screw up something on it.
I will rebuild entire project then try again.
-----------------
I am mix debug and release version.
After rebuild all, it works fine.
My bad.