[Verse-dev] Using <stdint.h> with Verse?

Emil Brink verse-dev@blender.org
Sat, 21 Feb 2004 17:29:44 +0100


On Sat, 21 Feb 2004 16:10:42 +0100
<a0054403@levonline.com> wrote:

> Hi
> 
> > I guess I should could have taken this directly with Eskil, but it's
> > more fun to use a list, and perhaps people on other platforms have
> > some input, too.
> 
> This is better.

Great.
> > Would it make sense to remove the typedefs for "uint32" and so on in
> > the Verse header, and just use the C99-standard uint32_t type (and
> > related ones for other sizes, of course) defined in <stdint.h>
> > instead?
> 
> Personally i would love to be able to code in C99 but the compiler
> have yet to catch up properly. As i understand sized integer types are
> built in in to C99 (defended as "_uint32" or something). And if
> everybody used C99 we would have used that in the implementation.

A compiler does not have to support all of C99 for these types to work.
All that is needed is a compiler-supplied (and -supported) <stdint.h>
header file.

This is in GCC, so all platforms using GCC should just work right away
(see http://gcc.gnu.org/c99status.html).

I don't have access to a Windows machine with development tools; if you
have then you could easily see if there is a "stdint.h" header file.

The C99 names are "uint32_t" and so on ("int8_t" for an example of a
signed type with known number of bits).

> However, referring to an outside .h file or lib, is a bad idea.

Yes, but a C API can always refer to standard C header files without
problems; they are not "outside" in the same sense as a third-party
library would be.

> it defeats the purpose of moving away form G-lib.

I disagree; a third-party library and a modern compiler are not the same
kind of dependency at all.

> To me the best way is to change it to have an C99 ifdef that defines
> our types using the C99s built in types, or use the current
> implementation.

But that still introduces "Verse-local" aliases for something that
should be provided by the compiler.

Doing it the other way is much cleaner; use the standard type names, and
define them if the platform lacks <stdint.h>. Then everybody wins.

/Emil