view src/main.c @ 3:d3d9c758a0ee

Published version
author Eris Caffee <discordia@eldalin.com>
date Thu, 21 Oct 2010 21:38:11 -0500
parents 837f5d6c4a72
children
line source
1 /******************************************************************************
2 //
3 // check-sdl-version
4 // Copyright (c) 2010 Eris Caffee
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 //
21 //
22 // Just a quick test program to verify SDL installation and to use as an
23 // example for learning to use CMake.
24 //
25 ******************************************************************************/
27 #include <stdio.h>
28 #include <SDL.h>
31 /* Redirect I/O on Windows to a file. We would not need to do this in a
32 console app. */
33 #ifdef WIN32
34 #include <windows.h>
35 #include <io.h>
36 void redirect_stdio(void)
37 {
38 /* We must freopen stderr to get it to have a valid fd before we can
39 dup it to stdout. This creates a file on disk, which we then delete. */
40 freopen("stdout.txt", "w", stdout);
41 freopen("stderr.txt", "w", stderr);
42 if (_dup2(_fileno(stdout), _fileno(stderr)) != 0)
43 fprintf(stdout, "_dup2 failed!\n");
44 DeleteFile("stderr.txt");
45 }
46 #endif
48 int main(int argc, char **argv)
49 {
50 SDL_version compiled;
51 const SDL_version * linked;
53 #ifdef WIN32
54 redirect_stdio();
55 #endif
57 printf("\t\t\tCompiled\t\tLinked\n");
59 SDL_VERSION(&compiled);
60 linked = SDL_Linked_Version();
61 printf("SDL version\t\t%d.%d.%d\t\t\t%d.%d.%d\n",
62 compiled.major, compiled.minor, compiled.patch,
63 linked->major, linked->minor, linked->patch);
65 return 0;
66 }