More fixes to compile under Visual C++
authorSam Lantinga <slouken@libsdl.org>
Sun, 22 Nov 2009 07:00:26 +0000
changeset 348278db4f7ae2f3
parent 3481 c32c53fca10d
child 3483 a54df8e52333
More fixes to compile under Visual C++
test/automated/SDL_at.c
test/automated/SDL_at.h
test/automated/common/common.c
test/automated/render/render.c
test/automated/rwops/rwops.c
test/automated/testsdl.c
     1.1 --- a/test/automated/SDL_at.c	Sun Nov 22 06:42:58 2009 +0000
     1.2 +++ b/test/automated/SDL_at.c	Sun Nov 22 07:00:26 2009 +0000
     1.3 @@ -242,7 +242,7 @@
     1.4     if (!condition) {
     1.5        /* Get message. */
     1.6        va_start( args, msg );
     1.7 -      vsnprintf( buf, sizeof(buf), msg, args );
     1.8 +      SDL_vsnprintf( buf, sizeof(buf), msg, args );
     1.9        va_end( args );
    1.10        /* Failed message. */
    1.11        SDL_ATassertFailed( buf );
    1.12 @@ -282,6 +282,31 @@
    1.13  
    1.14  
    1.15  /**
    1.16 + * @brief Displays a message.
    1.17 + */
    1.18 +int SDL_ATprint( const char *msg, ... )
    1.19 +{
    1.20 +   va_list ap;
    1.21 +   int ret;
    1.22 +
    1.23 +   /* Only print if not quiet. */
    1.24 +   if (at_quiet)
    1.25 +      return 0;
    1.26 +
    1.27 +   /* Make sure there is something to print. */
    1.28 +   if (msg == NULL)
    1.29 +      return 0;
    1.30 +   else {
    1.31 +      va_start(ap, msg);
    1.32 +      ret = vfprintf( stdout, msg, ap );
    1.33 +      va_end(ap);
    1.34 +   }
    1.35 +
    1.36 +   return ret;
    1.37 +}
    1.38 +
    1.39 +
    1.40 +/**
    1.41   * @brief Displays a verbose message.
    1.42   */
    1.43  int SDL_ATprintVerbose( int level, const char *msg, ... )
     2.1 --- a/test/automated/SDL_at.h	Sun Nov 22 06:42:58 2009 +0000
     2.2 +++ b/test/automated/SDL_at.h	Sun Nov 22 07:00:26 2009 +0000
     2.3 @@ -136,8 +136,7 @@
     2.4   *    @param msg printf formatted string to display.
     2.5   *    @return Number of character printed.
     2.6   */
     2.7 -#define SDL_ATprint(msg, args...) \
     2.8 -   SDL_ATprintVerbose( 0, msg, ## args)
     2.9 +int SDL_ATprint( const char *msg, ... );
    2.10  /**
    2.11   * @brief Prints some verbose text.
    2.12   *
     3.1 --- a/test/automated/common/common.c	Sun Nov 22 06:42:58 2009 +0000
     3.2 +++ b/test/automated/common/common.c	Sun Nov 22 07:00:26 2009 +0000
     3.3 @@ -42,7 +42,7 @@
     3.4              case 2:
     3.5              case 3:
     3.6                 ret += 1;
     3.7 -               printf("%d BPP not supported yet.\n",bpp);
     3.8 +               /*printf("%d BPP not supported yet.\n",bpp);*/
     3.9                 break;
    3.10  
    3.11              case 4:
    3.12 @@ -86,9 +86,9 @@
    3.13        if (bpp == 4) {
    3.14           for (j=0; j<sur->h; j++) {
    3.15              for (i=0; i<sur->w; i++) {
    3.16 +               Uint8 R, G, B, A;
    3.17                 p  = (Uint8 *)sur->pixels + j * sur->pitch + i * bpp;
    3.18                 pd = (Uint8 *)img->pixel_data + (j*img->width + i) * img->bytes_per_pixel;
    3.19 -               Uint8 R, G, B, A;
    3.20  
    3.21                 R = pd[0];
    3.22                 G = pd[1];
     4.1 --- a/test/automated/render/render.c	Sun Nov 22 06:42:58 2009 +0000
     4.2 +++ b/test/automated/render/render.c	Sun Nov 22 07:00:26 2009 +0000
     4.3 @@ -55,8 +55,6 @@
     4.4   */
     4.5  static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error )
     4.6  {
     4.7 -   (void) msg;
     4.8 -   (void) s;
     4.9     int ret;
    4.10     Uint8 pix[4*80*60];
    4.11     SDL_Surface *testsur;
    4.12 @@ -1005,7 +1003,7 @@
    4.13        /*
    4.14         * Initialize testsuite.
    4.15         */
    4.16 -      snprintf( msg, sizeof(msg) , "Rendering with %s driver", driver );
    4.17 +      SDL_snprintf( msg, sizeof(msg) , "Rendering with %s driver", driver );
    4.18        SDL_ATinit( msg );
    4.19  
    4.20        /*
    4.21 @@ -1018,7 +1016,7 @@
    4.22           goto err_cleanup;
    4.23        /* Check to see if it's the one we want. */
    4.24        str = SDL_GetCurrentVideoDriver();
    4.25 -      if (SDL_ATassert( "SDL_GetCurrentVideoDriver", strcmp(driver,str)==0))
    4.26 +      if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0))
    4.27           goto err_cleanup;
    4.28        /* Create window. */
    4.29        wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
    4.30 @@ -1027,7 +1025,7 @@
    4.31           goto err_cleanup;
    4.32        /* Check title. */
    4.33        str = SDL_GetWindowTitle( wid );
    4.34 -      if (SDL_ATassert( "SDL_GetWindowTitle", strcmp(msg,str)==0))
    4.35 +      if (SDL_ATassert( "SDL_GetWindowTitle", SDL_strcmp(msg,str)==0))
    4.36           goto err_cleanup;
    4.37        /* Get renderers. */
    4.38        nr = SDL_GetNumRenderDrivers();
    4.39 @@ -1051,7 +1049,7 @@
    4.40              goto err_cleanup;
    4.41  
    4.42           /* Set testcase name. */
    4.43 -         snprintf( msg, sizeof(msg), "Renderer %s", renderer.name );
    4.44 +         SDL_snprintf( msg, sizeof(msg), "Renderer %s", renderer.name );
    4.45           SDL_ATprintVerbose( 1, "    %d) %s\n", j+1, renderer.name );
    4.46           SDL_ATbegin( msg );
    4.47  
     5.1 --- a/test/automated/rwops/rwops.c	Sun Nov 22 06:42:58 2009 +0000
     5.2 +++ b/test/automated/rwops/rwops.c	Sun Nov 22 07:00:26 2009 +0000
     5.3 @@ -100,7 +100,7 @@
     5.4     if (SDL_ATassert( "Reading with SDL_RWread", i == sizeof(hello_world)-1 ))
     5.5        return 1;
     5.6     if (SDL_ATassert( "Memory read does not match memory written",
     5.7 -            memcmp( buf, hello_world, sizeof(hello_world)-1 ) == 0 ))
     5.8 +            SDL_memcmp( buf, hello_world, sizeof(hello_world)-1 ) == 0 ))
     5.9        return 1;
    5.10  
    5.11     /* More seek tests. */
     6.1 --- a/test/automated/testsdl.c	Sun Nov 22 06:42:58 2009 +0000
     6.2 +++ b/test/automated/testsdl.c	Sun Nov 22 07:00:26 2009 +0000
     6.3 @@ -16,17 +16,21 @@
     6.4  #include "render/render.h"
     6.5  #include "audio/audio.h"
     6.6  
     6.7 +#if defined(WIN32)
     6.8 +#define NO_GETOPT
     6.9 +#endif
    6.10  #if defined(__QNXNTO__)
    6.11  #define NO_GETOPT_LONG 1
    6.12  #endif /* __QNXNTO__ */
    6.13  
    6.14  #include <stdio.h> /* printf */
    6.15  #include <stdlib.h> /* exit */
    6.16 +#ifndef NO_GETOPT
    6.17  #include <unistd.h> /* getopt */
    6.18 -#include <string.h> /* strcmp */
    6.19  #if !defined(NO_GETOPT_LONG)
    6.20  #include <getopt.h> /* getopt_long */
    6.21  #endif /* !NO_GETOPT_LONG */
    6.22 +#endif /* !NO_GETOPT */
    6.23  
    6.24  
    6.25  /*
    6.26 @@ -51,6 +55,11 @@
    6.27  /**
    6.28   * @brief Displays program usage.
    6.29   */
    6.30 +#ifdef NO_GETOPT
    6.31 +static void print_usage( const char *name )
    6.32 +{
    6.33 +}
    6.34 +#else
    6.35  #if !defined(NO_GETOPT_LONG)
    6.36  static void print_usage( const char *name )
    6.37  {
    6.38 @@ -84,10 +93,16 @@
    6.39     printf("   -h,     display this message and exit\n");
    6.40  }
    6.41  #endif /* NO_GETOPT_LONG */
    6.42 +#endif /* NO_GETOPT */
    6.43  
    6.44  /**
    6.45   * @brief Handles the options.
    6.46   */
    6.47 +#ifdef NO_GETOPT
    6.48 +static void parse_options( int argc, char *argv[] )
    6.49 +{
    6.50 +}
    6.51 +#else
    6.52  #if !defined(NO_GETOPT_LONG)
    6.53  static void parse_options( int argc, char *argv[] )
    6.54  {
    6.55 @@ -239,6 +254,7 @@
    6.56     }
    6.57  }
    6.58  #endif /* NO_GETOPT_LONG */
    6.59 +#endif /* NO_GETOPT */
    6.60  
    6.61  /**
    6.62   * @brief Main entry point.
    6.63 @@ -283,7 +299,7 @@
    6.64              ver.major, ver.minor, ver.patch, rev );
    6.65        SDL_ATprintErr( "System is running %s and is %s endian\n",
    6.66              SDL_GetPlatform(),
    6.67 -#ifdef SDL_LIL_ENDIAN
    6.68 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN
    6.69              "little"
    6.70  #else
    6.71              "big"