| Summary: | Different size for wchar_t on Linux and Windows | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Imants <capsexe> |
| Component: | build | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | philipp.wiesemann |
| Version: | 2.0.4 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
This is not a bug, wchar_t is not a platform independent type, and is different sizes on Windows vs Linux. |
I am using SDl2.dll on Windows and libSDL2.so on Linux I was testing out wide string functionality when I saw that it behaved differently across diferent platforms SDL_wcslen. Code: var WStr: array [0..7] of WideChar; //one char 2 bytes begin WStr[0] := 'a'; WStr[1] := #0; AssertEquals(1, SDL_wcslen(WStr)); //Work on Windows fails on Linux end; var WStr: array [0..7] of Integer; //one char 4 bytes begin WStr[0] := Ord('a'); WStr[1] := 0; AssertEquals(1, SDL_wcslen(WStr)); //Work on Linux fails on Windows end; It looks like to me that in SDL2.dll wchar_t is 2 bytes long and in libSDL2.so it is 4 bytes long. I have question is it true or is it bug? Or it is 4 bytes long in bought but windows magically works?