[OT]-Visual Studio/Code::Blocks Troubles... |
MrTAToad
|
I presume you have #include <fstream> ?
|
|||||||||||
|
MrTAToad
|
Could also try std::fstream::in too, just on case
|
|||||||||||
|
MrTAToad
|
Could also try std::fstream::in
|
|||||||||||
|
JeZ-l-Lee
|
Hi,
Thanks. We already have "#include <fstream>". We tried changing it to "std::fstream::in" but it still has error? Any other ideas? Thanks! |
|||||||||||
|
MrTAToad
|
Have you made sure your project settings are setup for wide characters (and not standard ASCII?)
|
|||||||||||
|
JeZ-l-Lee
|
Ok, any idea how to setup Code::Blocks to support wide characters? (Google was no help) Thanks! |
|||||||||||||
|
[OT]-Visual Studio/Code::Blocks Troubles... |
Alex Baines
Guest
|
The problem is that the fstream.open method which takes a wchar_t* is a
non-standard addition to MSVC's standard library. You could try setting Code::Blocks to use the Microsoft C++ SDK if it can, that way the current code should work. If it's using GCC or a derivative like mingw, then you can possibly use the stdio_filebuf extension instead, like so: #if __WINDOWS__ wchar_t *wstr = (wchar_t *)SDL_iconv_utf8_ucs2(filename); #ifdef __GNUC__ __gnu_cxx::stdio_filebuf<char> filebuf(_wfopen(wstr, L"rb"), ios::in); basic_istream<char> fileStream(&filebuf); #else fstream fileStream(wstr, fstream::in); #endif SDL_free(wstr); #else fstream fileStream(filename, fstream::in); #endif you might need to add the following earlier in the file: #ifdef __GNUC__ #include <ext/stdio_filebuf.h> #endif On 02/05/15 03:38, JeZ-l-Lee wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
JeZ-l-Lee
|
Hi,
Thanks for the code.
We added the new code but have error:
What we do now? Thanks! |
|||||||||||||||||
|
[OT]-Visual Studio/Code::Blocks Troubles... |
Alex Baines
Guest
|
It's a bit of a hack, but you can use reinterpret_cast<basic_filebuf<char>*>(fileStream.rdbuf())->is_open() instead of fileStream.is_open() Also, now that I think about it you might need to add: #if __WINDOWS__ && __GNUC__ fclose(filebuf.file()); #endif when you're done reading, to make sure the file is closed. And in the writing code change basic_istream to basic_ofstream and L"rb" to L"wb". Kinda messy, unfortunately. You might be better off ditching the fstreams and using something like SDL_RWops that handle the unicode conversion transparently if you want cleaner code. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: [OT]-Visual Studio/Code::Blocks Troubles... |
JeZ-l-Lee
|
Forgive, but I never used SDL_RWops before... Could someone give an example which would work? Thanks! |
|||||||||||||
|
[OT]-Visual Studio/Code::Blocks Troubles... |
Alex Baines
Guest
|
There's an example on this page: https://wiki.libsdl.org/SDL_RWwrite
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|