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