From: <and...@us...> - 2011-10-21 10:02:16
|
Revision: 11996 http://plplot.svn.sourceforge.net/plplot/?rev=11996&view=rev Author: andrewross Date: 2011-10-21 10:02:09 +0000 (Fri, 21 Oct 2011) Log Message: ----------- Implement UNUSED() macro in plplotP.h to mark unused parameters as such. Use this to remove all warnings from src/plargs.c as this is one of the worst offenders. I would welcome feedback before propogating this further. Modified Paths: -------------- trunk/include/plplotP.h trunk/src/plargs.c Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2011-10-21 10:00:26 UTC (rev 11995) +++ trunk/include/plplotP.h 2011-10-21 10:02:09 UTC (rev 11996) @@ -279,6 +279,17 @@ #define HUGE_VAL ( 1.0 / 0.0 ) #endif +// Macro to mark function parameters as unused. +// For gcc this uses the unused attribute to remove compiler warnings. +// For all compilers the parameter name is also mangled to prevent +// accidental use. +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#else +# define UNUSED(x) UNUSED_ ## x +#endif + //-------------------------------------------------------------------------- // PLPLOT control macros //-------------------------------------------------------------------------- Modified: trunk/src/plargs.c =================================================================== --- trunk/src/plargs.c 2011-10-21 10:00:26 UTC (rev 11995) +++ trunk/src/plargs.c 2011-10-21 10:02:09 UTC (rev 11996) @@ -114,7 +114,7 @@ static void Syntax( void ); #ifndef PL_DEPRECATED -int plSetOpt( const char *opt, const char *opt_arg ); +int plSetOpt( const char * opt, const char *opt_arg ); #endif // Option handlers @@ -724,13 +724,13 @@ //-------------------------------------------------------------------------- int -plSetOpt( const char *opt, const char *opt_arg ) +plSetOpt( const char * opt, const char *opt_arg ) { return ( c_plsetopt( opt, opt_arg ) ); } int -c_plsetopt( const char *opt, const char *opt_arg ) +c_plsetopt( const char * opt, const char *opt_arg ) { int mode = 0, argc = 2, status; const char *argv[3]; @@ -1018,7 +1018,7 @@ //-------------------------------------------------------------------------- static int -ProcessOpt( const char *opt, PLOptionTable *tab, int *p_myargc, const char ***p_argv, +ProcessOpt( const char * opt, PLOptionTable *tab, int *p_myargc, const char ***p_argv, int *p_argc ) { int need_arg, res; @@ -1479,7 +1479,7 @@ //-------------------------------------------------------------------------- static int -opt_h( const char *opt, const char *opt_arg, void *client_data ) +opt_h( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { if ( !mode_quiet ) Help(); @@ -1495,7 +1495,7 @@ //-------------------------------------------------------------------------- static int -opt_v( const char *opt, const char *opt_arg, void *client_data ) +opt_v( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { if ( !mode_quiet ) fprintf( stderr, "PLplot library version: %s\n", VERSION ); @@ -1511,7 +1511,7 @@ //-------------------------------------------------------------------------- static int -opt_verbose( const char *opt, const char *opt_arg, void *client_data ) +opt_verbose( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsc->verbose = 1; return 0; @@ -1525,7 +1525,7 @@ //-------------------------------------------------------------------------- static int -opt_debug( const char *opt, const char *opt_arg, void *client_data ) +opt_debug( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsc->debug = 1; plsc->verbose = 1; @@ -1540,7 +1540,7 @@ //-------------------------------------------------------------------------- static int -opt_hack( const char *opt, const char *opt_arg, void *client_data ) +opt_hack( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsc->hack = 1; return 0; @@ -1554,7 +1554,7 @@ //-------------------------------------------------------------------------- static int -opt_dev( const char *opt, const char *opt_arg, void *client_data ) +opt_dev( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsdev( opt_arg ); return 0; @@ -1568,7 +1568,7 @@ //-------------------------------------------------------------------------- static int -opt_o( const char *opt, const char *opt_arg, void *client_data ) +opt_o( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsfnam( opt_arg ); return 0; @@ -1582,7 +1582,7 @@ //-------------------------------------------------------------------------- static int -opt_mar( const char *opt, const char *opt_arg, void *client_data ) +opt_mar( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsdidev( atof( opt_arg ), PL_NOTSET, PL_NOTSET, PL_NOTSET ); return 0; @@ -1596,7 +1596,7 @@ //-------------------------------------------------------------------------- static int -opt_a( const char *opt, const char *opt_arg, void *client_data ) +opt_a( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsdidev( PL_NOTSET, atof( opt_arg ), PL_NOTSET, PL_NOTSET ); return 0; @@ -1610,7 +1610,7 @@ //-------------------------------------------------------------------------- static int -opt_jx( const char *opt, const char *opt_arg, void *client_data ) +opt_jx( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsdidev( PL_NOTSET, PL_NOTSET, atof( opt_arg ), PL_NOTSET ); return 0; @@ -1624,7 +1624,7 @@ //-------------------------------------------------------------------------- static int -opt_jy( const char *opt, const char *opt_arg, void *client_data ) +opt_jy( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsdidev( PL_NOTSET, PL_NOTSET, PL_NOTSET, atof( opt_arg ) ); return 0; @@ -1638,7 +1638,7 @@ //-------------------------------------------------------------------------- static int -opt_ori( const char *opt, const char *opt_arg, void *client_data ) +opt_ori( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsdiori( atof( opt_arg ) ); return 0; @@ -1652,7 +1652,7 @@ //-------------------------------------------------------------------------- static int -opt_freeaspect( const char *opt, const char *opt_arg, void *client_data ) +opt_freeaspect( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsc->freeaspect = 1; return 0; @@ -1680,7 +1680,7 @@ //-------------------------------------------------------------------------- static int -opt_portrait( const char *opt, const char *opt_arg, void *client_data ) +opt_portrait( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsc->portrait = 1; return 0; @@ -1694,7 +1694,7 @@ //-------------------------------------------------------------------------- static int -opt_width( const char *opt, const char *opt_arg, void *client_data ) +opt_width( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { int width; @@ -1724,7 +1724,7 @@ //-------------------------------------------------------------------------- static int -opt_bg( const char *opt, const char *opt_arg, void *client_data ) +opt_bg( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { const char *rgb; char *color_field, *alpha_field; @@ -1800,7 +1800,7 @@ //-------------------------------------------------------------------------- static int -opt_ncol0( const char *opt, const char *opt_arg, void *client_data ) +opt_ncol0( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->ncol0 = atoi( opt_arg ); return 0; @@ -1814,7 +1814,7 @@ //-------------------------------------------------------------------------- static int -opt_ncol1( const char *opt, const char *opt_arg, void *client_data ) +opt_ncol1( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->ncol1 = atoi( opt_arg ); return 0; @@ -1828,7 +1828,7 @@ //-------------------------------------------------------------------------- static int -opt_wplt( const char *opt, const char *opt_arg, void *client_data ) +opt_wplt( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { char *field; PLFLT xl, yl, xr, yr; @@ -1868,7 +1868,7 @@ //-------------------------------------------------------------------------- static int -opt_drvopt( const char *opt, const char *opt_arg, void *client_data ) +opt_drvopt( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { char t, *tt, *option, *value; int fl = 0; @@ -1951,7 +1951,7 @@ //-------------------------------------------------------------------------- static int -opt_fam( const char *opt, const char *opt_arg, void *client_data ) +opt_fam( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsfam( 1, -1, -1 ); return 0; @@ -1974,7 +1974,7 @@ //-------------------------------------------------------------------------- static int -opt_fsiz( const char *opt, const char *opt_arg, void *client_data ) +opt_fsiz( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { PLINT bytemax; size_t len = strlen( opt_arg ); @@ -2025,7 +2025,7 @@ //-------------------------------------------------------------------------- static int -opt_fbeg( const char *opt, const char *opt_arg, void *client_data ) +opt_fbeg( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->member = atoi( opt_arg ); @@ -2040,7 +2040,7 @@ //-------------------------------------------------------------------------- static int -opt_finc( const char *opt, const char *opt_arg, void *client_data ) +opt_finc( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->finc = atoi( opt_arg ); @@ -2055,7 +2055,7 @@ //-------------------------------------------------------------------------- static int -opt_fflen( const char *opt, const char *opt_arg, void *client_data ) +opt_fflen( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->fflen = atoi( opt_arg ); @@ -2070,7 +2070,7 @@ //-------------------------------------------------------------------------- static int -opt_np( const char *opt, const char *opt_arg, void *client_data ) +opt_np( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plspause( 0 ); return 0; @@ -2084,7 +2084,7 @@ //-------------------------------------------------------------------------- static int -opt_nopixmap( const char *opt, const char *opt_arg, void *client_data ) +opt_nopixmap( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsc->nopixmap = 1; return 0; @@ -2098,7 +2098,7 @@ //-------------------------------------------------------------------------- static int -opt_db( const char *opt, const char *opt_arg, void *client_data ) +opt_db( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsc->db = 1; return 0; @@ -2112,7 +2112,7 @@ //-------------------------------------------------------------------------- static int -opt_bufmax( const char *opt, const char *opt_arg, void *client_data ) +opt_bufmax( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->bufmax = atoi( opt_arg ); return 0; @@ -2126,7 +2126,7 @@ //-------------------------------------------------------------------------- static int -opt_server_name( const char *opt, const char *opt_arg, void *client_data ) +opt_server_name( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->server_name = plstrdup( opt_arg ); return 0; @@ -2140,7 +2140,7 @@ //-------------------------------------------------------------------------- static int -opt_plserver( const char *opt, const char *opt_arg, void *client_data ) +opt_plserver( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->plserver = plstrdup( opt_arg ); return 0; @@ -2154,7 +2154,7 @@ //-------------------------------------------------------------------------- static int -opt_plwindow( const char *opt, const char *opt_arg, void *client_data ) +opt_plwindow( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { if ( ( plsc->plwindow = (char *) malloc( (size_t) ( 1 + strlen( opt_arg ) ) * sizeof ( char ) ) ) == NULL ) { @@ -2172,7 +2172,7 @@ //-------------------------------------------------------------------------- static int -opt_auto_path( const char *opt, const char *opt_arg, void *client_data ) +opt_auto_path( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plsc->auto_path = plstrdup( opt_arg ); return 0; @@ -2186,7 +2186,7 @@ //-------------------------------------------------------------------------- static int -opt_px( const char *opt, const char *opt_arg, void *client_data ) +opt_px( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plssub( atoi( opt_arg ), -1 ); return 0; @@ -2200,7 +2200,7 @@ //-------------------------------------------------------------------------- static int -opt_py( const char *opt, const char *opt_arg, void *client_data ) +opt_py( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plssub( -1, atoi( opt_arg ) ); return 0; @@ -2218,7 +2218,7 @@ //-------------------------------------------------------------------------- static int -opt_geo( const char *opt, const char *opt_arg, void *client_data ) +opt_geo( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { int numargs; PLFLT xdpi = 0., ydpi = 0.; @@ -2304,7 +2304,7 @@ //-------------------------------------------------------------------------- static int -opt_tk_file( const char *opt, const char *opt_arg, void *client_data ) +opt_tk_file( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { if ( ( plsc->tk_file = (char *) malloc( (size_t) ( 1 + strlen( opt_arg ) ) * sizeof ( char ) ) ) == NULL ) { @@ -2327,7 +2327,7 @@ //-------------------------------------------------------------------------- static int -opt_dpi( const char *opt, const char *opt_arg, void *client_data ) +opt_dpi( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { char *field; PLFLT xdpi = 0., ydpi = 0.; @@ -2368,7 +2368,7 @@ //-------------------------------------------------------------------------- static int -opt_dev_compression( const char *opt, const char *opt_arg, void *client_data ) +opt_dev_compression( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { PLINT comp = 0; @@ -2390,7 +2390,7 @@ //-------------------------------------------------------------------------- static int -opt_cmap0( const char *opt, const char *opt_arg, void *client_data ) +opt_cmap0( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plspal0( opt_arg ); return 0; @@ -2403,7 +2403,7 @@ //-------------------------------------------------------------------------- static int -opt_cmap1( const char *opt, const char *opt_arg, void *client_data ) +opt_cmap1( const char * UNUSED(opt), const char *opt_arg, void * UNUSED(client_data) ) { plspal1( opt_arg, TRUE ); return 0; @@ -2416,7 +2416,7 @@ //-------------------------------------------------------------------------- static int -opt_locale( const char *opt, const char *opt_arg, void *client_data ) +opt_locale( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { char *locale; if ( ( locale = setlocale( LC_NUMERIC, "" ) ) ) @@ -2443,7 +2443,7 @@ //-------------------------------------------------------------------------- static int -opt_eofill( const char *opt, const char *opt_arg, void *client_data ) +opt_eofill( const char * UNUSED(opt), const char * UNUSED(opt_arg), void * UNUSED(client_data) ) { plsc->dev_eofill = 1; return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |