Stdint.h, pstdint.h, and SDL

On Visual Studio, compiling a project that uses “pstdint.h” is quite
annoying. The file “pstdint.h” is a portable replacement for <stdint.h> for
environments which don’t have <stdint.h>. For those that do, it just simply
includes <stdint.h>

Microsoft Visual C++ 2008 doesn’t have it, so it provides a set of useful
definitions, however SDL on Visual C++ does this as well:

(sdl_config_win32.h)

#if defined(GNUC) || defined(DMC)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;

In this case, the definitions conflict. I can modify one header or the
other, but since these both come from external sources, I can’t really just
modify my set headers and expect it work on other’s machines. SDL doesn’t
provide the full set of types for <stdint.h>, so using “pstdint.h” is still
required. Here are the possible solutions:

  • Use “pstdint.h” in SDL (bsd license) on Win32 systems
  • Change #elif defined(_MSC_VER) to #elif (defined(_MSC_VER) &&
    (!defined(HAVE_STDINT_H) || HAVE_STDINT_T == 0))
  • Provide full stdint.h types for SDL
  • Something else that I can’t think of this late at night
  • Don’t provide or use int32_t, uint32_t, etc. in SDL
  • Something else I can’t think of this late at night

Any ideas? :\

Patrick

One other data point to consider. I’ve heard (but want somebody to
verify) that the latest Visual Studio version finally provides
stdint.h. If true, I think we should be using the native one when
available.

-EricOn 3/15/11, Patrick Baggett <baggett.patrick at gmail.com> wrote:

On Visual Studio, compiling a project that uses “pstdint.h” is quite
annoying. The file “pstdint.h” is a portable replacement for <stdint.h> for
environments which don’t have <stdint.h>. For those that do, it just simply
includes <stdint.h>

Microsoft Visual C++ 2008 doesn’t have it, so it provides a set of useful
definitions, however SDL on Visual C++ does this as well:

(sdl_config_win32.h)

#if defined(GNUC) || defined(DMC)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;

In this case, the definitions conflict. I can modify one header or the
other, but since these both come from external sources, I can’t really just
modify my set headers and expect it work on other’s machines. SDL doesn’t
provide the full set of types for <stdint.h>, so using “pstdint.h” is still
required. Here are the possible solutions:

  • Use “pstdint.h” in SDL (bsd license) on Win32 systems
  • Change #elif defined(_MSC_VER) to #elif (defined(_MSC_VER) &&
    (!defined(HAVE_STDINT_H) || HAVE_STDINT_T == 0))
  • Provide full stdint.h types for SDL
  • Something else that I can’t think of this late at night
  • Don’t provide or use int32_t, uint32_t, etc. in SDL
  • Something else I can’t think of this late at night

Any ideas? :\

Patrick


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

I can confirm that Visual Studio 2010 does finally include stdint.h. I was
able to remove pstdint.h from several projects last month after upgrading.

JustinOn Tue, Mar 15, 2011 at 11:42 PM, Eric Wing wrote:

On 3/15/11, Patrick Baggett <baggett.patrick at gmail.com> wrote:

On Visual Studio, compiling a project that uses “pstdint.h” is quite
annoying. The file “pstdint.h” is a portable replacement for <stdint.h>
for
environments which don’t have <stdint.h>. For those that do, it just
simply
includes <stdint.h>

Microsoft Visual C++ 2008 doesn’t have it, so it provides a set of useful
definitions, however SDL on Visual C++ does this as well:

(sdl_config_win32.h)

#if defined(GNUC) || defined(DMC)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;

In this case, the definitions conflict. I can modify one header or the
other, but since these both come from external sources, I can’t really
just
modify my set headers and expect it work on other’s machines. SDL doesn’t
provide the full set of types for <stdint.h>, so using “pstdint.h” is
still
required. Here are the possible solutions:

  • Use “pstdint.h” in SDL (bsd license) on Win32 systems
  • Change #elif defined(_MSC_VER) to #elif (defined(_MSC_VER) &&
    (!defined(HAVE_STDINT_H) || HAVE_STDINT_T == 0))
  • Provide full stdint.h types for SDL
  • Something else that I can’t think of this late at night
  • Don’t provide or use int32_t, uint32_t, etc. in SDL
  • Something else I can’t think of this late at night

Any ideas? :\

Patrick

One other data point to consider. I’ve heard (but want somebody to
verify) that the latest Visual Studio version finally provides
stdint.h. If true, I think we should be using the native one when
available.

-Eric

Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Does that mean we will use uint32_t instead of SDL Uint32?

Cheers,On 16/03/2011 07:10, Patrick Baggett wrote:

On Visual Studio, compiling a project that uses “pstdint.h” is quite
annoying. The file “pstdint.h” is a portable replacement for <stdint.h>
for environments which don’t have <stdint.h>. For those that do, it just
simply includes <stdint.h>

Microsoft Visual C++ 2008 doesn’t have it, so it provides a set of
useful definitions, however SDL on Visual C++ does this as well:

(sdl_config_win32.h)

#if defined(GNUC) || defined(DMC)
#define HAVE_STDINT_H1
#elif defined(_MSC_VER)
typedef signed __int8int8_t;
typedef unsigned __int8uint8_t;
typedef signed __int16int16_t;
typedef unsigned __int16uint16_t;
typedef signed __int32int32_t;
typedef unsigned __int32uint32_t;
typedef signed __int64int64_t;
typedef unsigned __int64uint64_t;

In this case, the definitions conflict. I can modify one header or the
other, but since these both come from external sources, I can’t really
just modify my set headers and expect it work on other’s machines. SDL
doesn’t provide the full set of types for <stdint.h>, so using
"pstdint.h" is still required. Here are the possible solutions:

* Use "pstdint.h" in SDL (bsd license) on Win32 systems
* Change #elif defined(_MSC_VER) to #elif (defined(_MSC_VER) &&
  (!defined(HAVE_STDINT_H) || HAVE_STDINT_T == 0))
* Provide full stdint.h types for SDL
* Something else that I can't think of this late at night
* Don't provide or use int32_t, uint32_t, etc. in SDL
* Something else I can't think of this late at night

Any ideas? :\

Patrick


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


David Demelier

On Visual Studio, compiling a project that uses “pstdint.h” is quite annoying. The file “pstdint.h” is a portable replacement for <stdint.h> for environments which don’t have <stdint.h>. For those that do, it just simply includes <stdint.h>

Microsoft Visual C++ 2008 doesn’t have it, so it provides a set of useful definitions, however SDL on Visual C++ does this as well:

(sdl_config_win32.h)

#if defined(GNUC) || defined(DMC)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;

In this case, the definitions conflict.

Applications/libraries should not attempt to supply replacements for apparently missing
standard functionality. This is bad practice. The right way to do this is very boring and very bad
in itself but it’s the right way:

SDL_int8_t … etc etc

Another way to do this is simpler and tempting:

simply specify “int8_t” is required. If your system doesn’t have it, then
it is the clients responsibility to provide it.

The reason applications shouldn’t provide replacements for missing
standard things is clear: two applications doing so cannot be used
together.

Allowing for client’s to provide missing stuff in configuration auxiliary
is very hard to do right. My system “Felix” copies such information from
the location $HOME/.felix/config.data during configuration in order that it isn’t clobbered
on rebuilding/reloading from repository/reinstalling etc.

GNU has a reasonable way to do this kind of thing: packages are installed
in TWO directories: the standard “platform independent” files go in
xx/include/.h and the config goes in xx_config/include/.h or something.
Then the former #includes files from the latter. The downside of this method
is that you can only have one copy of the platform specific data.
(That could be fixed by a mandatory environment variable but now the
system doesn’t work without it and this will cause havoc).On 16/03/2011, at 5:10 PM, Patrick Baggett wrote:


john skaller
@john_skaller