test/testtypes.c
changeset 1154 d93862a3d821
parent 47 45b1c4303f87
child 1387 835c1831f903
     1.1 --- a/test/testtypes.c	Sun Oct 02 00:50:03 2005 +0000
     1.2 +++ b/test/testtypes.c	Mon Oct 03 08:12:32 2005 +0000
     1.3 @@ -1,8 +1,20 @@
     1.4  
     1.5  #include <stdio.h>
     1.6 +#include <stdlib.h>
     1.7 +#include <string.h>
     1.8  #include "SDL_main.h"
     1.9  #include "SDL_types.h"
    1.10  
    1.11 +/*
    1.12 + * Watcom C flags these as Warning 201: "Unreachable code" if you just
    1.13 + *  compare them directly, so we push it through a function to keep the
    1.14 + *  compiler quiet.  --ryan.
    1.15 + */
    1.16 +static int badsize(size_t sizeoftype, size_t hardcodetype)
    1.17 +{
    1.18 +    return sizeoftype != hardcodetype;
    1.19 +}
    1.20 +
    1.21  int main(int argc, char *argv[])
    1.22  {
    1.23  	int error = 0;
    1.24 @@ -11,26 +23,26 @@
    1.25  	if ( argv[1] && (strcmp(argv[1], "-q") == 0) )
    1.26  		verbose = 0;
    1.27  
    1.28 -	if ( sizeof(Uint8) != 1 ) {
    1.29 +	if ( badsize(sizeof(Uint8), 1) ) {
    1.30  		if ( verbose )
    1.31  			printf("sizeof(Uint8) != 1, instead = %d\n",
    1.32  								sizeof(Uint8));
    1.33  		++error;
    1.34  	}
    1.35 -	if ( sizeof(Uint16) != 2 ) {
    1.36 +	if ( badsize(sizeof(Uint16), 2) ) {
    1.37  		if ( verbose )
    1.38  			printf("sizeof(Uint16) != 2, instead = %d\n",
    1.39  								sizeof(Uint16));
    1.40  		++error;
    1.41  	}
    1.42 -	if ( sizeof(Uint32) != 4 ) {
    1.43 +	if ( badsize(sizeof(Uint32), 4) ) {
    1.44  		if ( verbose )
    1.45  			printf("sizeof(Uint32) != 4, instead = %d\n",
    1.46  								sizeof(Uint32));
    1.47  		++error;
    1.48  	}
    1.49  #ifdef SDL_HAS_64BIT_TYPE
    1.50 -	if ( sizeof(Uint64) != 8 ) {
    1.51 +	if ( badsize(sizeof(Uint64), 8) ) {
    1.52  		if ( verbose )
    1.53  			printf("sizeof(Uint64) != 8, instead = %d\n",
    1.54  								sizeof(Uint64));