Try to suppress MSVC++ unused parameter warnings.

I haven't found a way to with MSVC to mark parameters in the argument
list as unused.  MSVC doesn't give warnings about them in C code, but
does appear to give them with C++ code.  An answer to

	http://stackoverflow.com/questions/3020584/avoid-warning-unreferenced-formal-parameter

suggests not giving the formal parameter a name in C++.

Have a macro UNUSED_PARAMETER(), which takes as an argument a variable
name, and expands to nothing in C++ and to the variable name followed by
_U_ in C, and use that for some unused parameters.  If it works, we'll
use it for all of them.

Change-Id: I76107bed037f1f0d94615adb42234c9faf83b4db
Reviewed-on: https://code.wireshark.org/review/4016
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-09-06 13:08:40 -07:00
parent afb939b5f4
commit 746a265f99
1 changed files with 11 additions and 5 deletions

View File

@ -332,6 +332,12 @@ char* uat_unbinstring(const char* si, guint in_len, guint* len_p);
char* uat_unesc(const char* si, guint in_len, guint* len_p);
char* uat_esc(const char* buf, guint len);
#ifdef __cplusplus
#define UNUSED_PARAMETER(n)
#else
#define UNUSED_PARAMETER(n) n _U_
#endif
/* Some strings entirely made of ... already declared */
WS_DLL_PUBLIC
CHK_STR_IS_DECL(isprint);
@ -345,7 +351,7 @@ WS_DLL_PUBLIC
CHK_STR_IS_DECL(isxdigit);
#define CHK_STR_IS_DEF(what) \
gboolean uat_fld_chk_str_ ## what (void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, const char** err) { \
gboolean uat_fld_chk_str_ ## what (void* UNUSED_PARAMETER(u1), const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, const char** err) { \
guint i; for (i=0;i<len;i++) { \
char c = strptr[i]; \
if (! what((int)c)) { \
@ -488,14 +494,14 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
* value
*/
#define UAT_VS_DEF(basename,field_name,rec_t,default_t,default_val,default_str) \
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* vs, const void* u2 _U_) {\
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* vs, const void* UNUSED_PARAMETER(u2)) {\
guint i; \
char* str = ep_strndup(buf,len); \
const char* cstr; ((rec_t*)rec)->field_name = default_val; \
for(i=0; ( cstr = ((const value_string*)vs)[i].strptr ) ;i++) { \
if (g_str_equal(cstr,str)) { \
((rec_t*)rec)->field_name = (default_t)((const value_string*)vs)[i].value; return; } } } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* vs, const void* u2 _U_) {\
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* vs, const void* UNUSED_PARAMETER(u2)) {\
guint i; \
*out_ptr = ep_strdup(default_str); \
*out_len = (unsigned)strlen(default_str);\
@ -505,14 +511,14 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
*out_len = (unsigned)strlen(*out_ptr); return; } } }
#define UAT_VS_CSTRING_DEF(basename,field_name,rec_t,default_val,default_str) \
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* vs, const void* u2 _U_) {\
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* vs, const void* UNUSED_PARAMETER(u2)) {\
guint i; \
char* str = ep_strndup(buf,len); \
const char* cstr; ((rec_t*)rec)->field_name = default_val; \
for(i=0; ( cstr = ((const value_string*)vs)[i].strptr ) ;i++) { \
if (g_str_equal(cstr,str)) { \
((rec_t*)rec)->field_name = g_strdup(((const value_string*)vs)[i].strptr); return; } } } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* vs _U_, const void* u2 _U_) {\
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(vs), const void* UNUSED_PARAMETER(u2)) {\
if (((rec_t*)rec)->field_name ) { \
*out_ptr = (((rec_t*)rec)->field_name); \
*out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \