We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3230

Summary: Different size for wchar_t on Linux and Windows
Product: SDL Reporter: Imants <capsexe>
Component: buildAssignee: 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   

Description Imants 2016-01-09 15:52:22 UTC
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?
Comment 1 Sam Lantinga 2016-01-10 02:14:31 UTC
This is not a bug, wchar_t is not a platform independent type, and is different sizes on Windows vs Linux.