test/testtypes.c
changeset 1154 d93862a3d821
parent 47 45b1c4303f87
child 1387 835c1831f903
equal deleted inserted replaced
1153:5bc98ce985c2 1154:d93862a3d821
     1 
     1 
     2 #include <stdio.h>
     2 #include <stdio.h>
       
     3 #include <stdlib.h>
       
     4 #include <string.h>
     3 #include "SDL_main.h"
     5 #include "SDL_main.h"
     4 #include "SDL_types.h"
     6 #include "SDL_types.h"
       
     7 
       
     8 /*
       
     9  * Watcom C flags these as Warning 201: "Unreachable code" if you just
       
    10  *  compare them directly, so we push it through a function to keep the
       
    11  *  compiler quiet.  --ryan.
       
    12  */
       
    13 static int badsize(size_t sizeoftype, size_t hardcodetype)
       
    14 {
       
    15     return sizeoftype != hardcodetype;
       
    16 }
     5 
    17 
     6 int main(int argc, char *argv[])
    18 int main(int argc, char *argv[])
     7 {
    19 {
     8 	int error = 0;
    20 	int error = 0;
     9 	int verbose = 1;
    21 	int verbose = 1;
    10 
    22 
    11 	if ( argv[1] && (strcmp(argv[1], "-q") == 0) )
    23 	if ( argv[1] && (strcmp(argv[1], "-q") == 0) )
    12 		verbose = 0;
    24 		verbose = 0;
    13 
    25 
    14 	if ( sizeof(Uint8) != 1 ) {
    26 	if ( badsize(sizeof(Uint8), 1) ) {
    15 		if ( verbose )
    27 		if ( verbose )
    16 			printf("sizeof(Uint8) != 1, instead = %d\n",
    28 			printf("sizeof(Uint8) != 1, instead = %d\n",
    17 								sizeof(Uint8));
    29 								sizeof(Uint8));
    18 		++error;
    30 		++error;
    19 	}
    31 	}
    20 	if ( sizeof(Uint16) != 2 ) {
    32 	if ( badsize(sizeof(Uint16), 2) ) {
    21 		if ( verbose )
    33 		if ( verbose )
    22 			printf("sizeof(Uint16) != 2, instead = %d\n",
    34 			printf("sizeof(Uint16) != 2, instead = %d\n",
    23 								sizeof(Uint16));
    35 								sizeof(Uint16));
    24 		++error;
    36 		++error;
    25 	}
    37 	}
    26 	if ( sizeof(Uint32) != 4 ) {
    38 	if ( badsize(sizeof(Uint32), 4) ) {
    27 		if ( verbose )
    39 		if ( verbose )
    28 			printf("sizeof(Uint32) != 4, instead = %d\n",
    40 			printf("sizeof(Uint32) != 4, instead = %d\n",
    29 								sizeof(Uint32));
    41 								sizeof(Uint32));
    30 		++error;
    42 		++error;
    31 	}
    43 	}
    32 #ifdef SDL_HAS_64BIT_TYPE
    44 #ifdef SDL_HAS_64BIT_TYPE
    33 	if ( sizeof(Uint64) != 8 ) {
    45 	if ( badsize(sizeof(Uint64), 8) ) {
    34 		if ( verbose )
    46 		if ( verbose )
    35 			printf("sizeof(Uint64) != 8, instead = %d\n",
    47 			printf("sizeof(Uint64) != 8, instead = %d\n",
    36 								sizeof(Uint64));
    48 								sizeof(Uint64));
    37 		++error;
    49 		++error;
    38 	}
    50 	}