nothings/stb — pull request #60 by dreamtea (2014-12-18 23:46:56+00:00)
Title: Add explicit wchar_t casts in stb.h

Hi,

I ran into the errors below when compiling stb.h with VS2013. Most of them are complaints that you can't implicitly cast unsigned short to and from wchar_t because the latter is now a built-in type. It's possible to get rid of them with the `/Zc:wchar_t-` switch, but that's not the default, so I thought it might be good to add some explicit casts.

A couple of the others were about the use of implicit-int or an implicit void return type which are also fixed in this commit.

The only one remaining is the use of `strdup()` instead of `_strdup()`. I didn't want to change that because I don't know if the version with the underscore is available on VC6. In any case that error can be turned off by defining `_CRT_NONSTDC_NO_WARNINGS`.

Thomas

P.S. Thanks for the great library!

```
stb.h(713): error C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h(245) : see declaration of 'strdup'
stb.h(1248): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
stb.h(5054): error C2664: 'int _wstat64i32(const wchar_t *,_stat64i32 *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5063): error C2664: 'int _wstat64i32(const wchar_t *,_stat64i32 *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5083): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5118): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5133): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5294): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5295): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5311): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5312): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5346): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5435): error C2664: 'int _wrename(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5464): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5468): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5840): error C2664: 'intptr_t _wfindfirst64i32(const wchar_t *,_wfinddata64i32_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(5858): error C2664: 'char *stb__to_utf8(stb__wchar *)' : cannot convert argument 1 from 'wchar_t [260]' to 'stb__wchar *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(6261): error C2664: 'FILE *_wfopen(const wchar_t *,const wchar_t *)' : cannot convert argument 1 from 'stb__wchar *' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(6807): error C2665: 'swprintf' : none of the 2 overloads could convert all the argument types
c:\program files (x86)\microsoft visual studio 12.0\vc\include\swprintf.inl(85): could be 'int swprintf(wchar_t *,const wchar_t *,...)'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\swprintf.inl(36): or 'int swprintf(wchar_t *,size_t,const wchar_t *,...)'
while trying to match the argument list '(stb__wchar [1024], const wchar_t [4], stb__wchar *)'
stb.h(6809): error C2665: 'swprintf' : none of the 2 overloads could convert all the argument types
c:\program files (x86)\microsoft visual studio 12.0\vc\include\swprintf.inl(85): could be 'int swprintf(wchar_t *,const wchar_t *,...)'
c:\program files (x86)\microsoft visual studio 12.0\vc\include\swprintf.inl(36): or 'int swprintf(wchar_t *,size_t,const wchar_t *,...)'
while trying to match the argument list '(stb__wchar [1024], const wchar_t [5], stb__wchar *)'
stb.h(6821): error C2664: 'intptr_t _wfindfirst64i32(const wchar_t *,_wfinddata64i32_t *)' : cannot convert argument 1 from 'stb__wchar [1024]' to 'const wchar_t *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(6827): error C2664: 'char *stb__to_utf8(stb__wchar *)' : cannot convert argument 1 from 'wchar_t [260]' to 'stb__wchar *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(6835): error C2664: 'char *stb__to_utf8(stb__wchar *)' : cannot convert argument 1 from 'wchar_t [260]' to 'stb__wchar *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
stb.h(11053): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
stb.h(11086): warning C4508: 'stb_arith_state_rescale' : function should return a value; 'void' return type assumed

```