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 - Different size for wchar_t on Linux and Windows
Summary: Different size for wchar_t on Linux and Windows
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: 2.0.4
Hardware: x86_64 Linux
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-09 15:52 UTC by Imants
Modified: 2016-01-10 02:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.