diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-09-06 13:08:40 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-09-06 20:09:16 +0000 |
commit | 746a265f9933f70bb8b8ded08d5c96e7d6cb0342 (patch) | |
tree | 415e8b85ac63f04fddefb61aca031a3723a0fe50 /epan/uat.h | |
parent | afb939b5f4a69e2f70ea43bc3c574ec2a3b8adeb (diff) |
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>
Diffstat (limited to 'epan/uat.h')
-rw-r--r-- | epan/uat.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/epan/uat.h b/epan/uat.h index f018f2378a..b6d6d404b7 100644 --- a/epan/uat.h +++ b/epan/uat.h @@ -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)); \ |