test/testtypes.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 20 Feb 2006 10:19:47 +0000
changeset 1387 835c1831f903
parent 1154 d93862a3d821
permissions -rw-r--r--
Tests require SDL 1.2.10
slouken@0
     1
slouken@0
     2
#include <stdio.h>
slouken@47
     3
#include "SDL_main.h"
slouken@1387
     4
#include "SDL_stdinc.h"
slouken@0
     5
icculus@1154
     6
/*
icculus@1154
     7
 * Watcom C flags these as Warning 201: "Unreachable code" if you just
icculus@1154
     8
 *  compare them directly, so we push it through a function to keep the
icculus@1154
     9
 *  compiler quiet.  --ryan.
icculus@1154
    10
 */
icculus@1154
    11
static int badsize(size_t sizeoftype, size_t hardcodetype)
icculus@1154
    12
{
icculus@1154
    13
    return sizeoftype != hardcodetype;
icculus@1154
    14
}
icculus@1154
    15
slouken@0
    16
int main(int argc, char *argv[])
slouken@0
    17
{
slouken@0
    18
	int error = 0;
slouken@0
    19
	int verbose = 1;
slouken@0
    20
slouken@0
    21
	if ( argv[1] && (strcmp(argv[1], "-q") == 0) )
slouken@0
    22
		verbose = 0;
slouken@0
    23
icculus@1154
    24
	if ( badsize(sizeof(Uint8), 1) ) {
slouken@0
    25
		if ( verbose )
slouken@0
    26
			printf("sizeof(Uint8) != 1, instead = %d\n",
slouken@0
    27
								sizeof(Uint8));
slouken@0
    28
		++error;
slouken@0
    29
	}
icculus@1154
    30
	if ( badsize(sizeof(Uint16), 2) ) {
slouken@0
    31
		if ( verbose )
slouken@0
    32
			printf("sizeof(Uint16) != 2, instead = %d\n",
slouken@0
    33
								sizeof(Uint16));
slouken@0
    34
		++error;
slouken@0
    35
	}
icculus@1154
    36
	if ( badsize(sizeof(Uint32), 4) ) {
slouken@0
    37
		if ( verbose )
slouken@0
    38
			printf("sizeof(Uint32) != 4, instead = %d\n",
slouken@0
    39
								sizeof(Uint32));
slouken@0
    40
		++error;
slouken@0
    41
	}
slouken@0
    42
#ifdef SDL_HAS_64BIT_TYPE
icculus@1154
    43
	if ( badsize(sizeof(Uint64), 8) ) {
slouken@0
    44
		if ( verbose )
slouken@0
    45
			printf("sizeof(Uint64) != 8, instead = %d\n",
slouken@0
    46
								sizeof(Uint64));
slouken@0
    47
		++error;
slouken@0
    48
	}
slouken@0
    49
#else
slouken@0
    50
	if ( verbose ) {
slouken@0
    51
		printf("WARNING: No 64-bit datatype on this platform\n");
slouken@0
    52
	}
slouken@0
    53
#endif
slouken@0
    54
	if ( verbose && ! error )
slouken@0
    55
		printf("All data types are the expected size.\n");
slouken@0
    56
slouken@0
    57
	return( error ? 1 : 0 );
slouken@0
    58
}