Skip to content

Commit 8f140b3

Browse files
Merge pull request #268 from ax3l/fix-warningUnusedStatic
Warning: Fix Unused
2 parents 6c6b71e + 6f901ba commit 8f140b3

2 files changed

Lines changed: 30 additions & 10 deletions

File tree

src/include/splash/core/H5IdWrapper.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
#ifndef H5ID_WRAPPER_HPP
2424
#define H5ID_WRAPPER_HPP
2525

26+
#include "splash/core/splashMacros.hpp"
27+
2628
#include <hdf5.h>
2729

30+
2831
namespace splash
2932
{
30-
3133
namespace policies
3234
{
3335
template<typename T>
@@ -36,10 +38,9 @@ namespace splash
3638
static T copy(const T&)
3739
{
3840
// Make it depend on template parameter
39-
static char copyNotAllowed[sizeof(T) ? -1 : 0];
40-
(void) copyNotAllowed;
41+
SPLASH_UNUSED static char copyNotAllowed[sizeof(T) ? -1 : 0];
4142
}
42-
43+
4344
static bool release(const T&)
4445
{
4546
return true;
@@ -53,13 +54,13 @@ namespace splash
5354
{
5455
*refCt_ = 1;
5556
}
56-
57+
5758
T copy(const T& obj)
5859
{
5960
++*refCt_;
6061
return obj;
6162
}
62-
63+
6364
bool release(const T&)
6465
{
6566
if(!--*refCt_)
@@ -70,7 +71,7 @@ namespace splash
7071
}
7172
return false;
7273
}
73-
74+
7475
friend void swap(RefCounted& lhs, RefCounted& rhs)
7576
{
7677
std::swap(lhs.refCt_, rhs.refCt_);
@@ -79,7 +80,7 @@ namespace splash
7980
unsigned* refCt_;
8081
};
8182
}
82-
83+
8384
/** RAII wrapper for a hid_t (HDF5 identifier)
8485
* Calls T_CloseMethod on destruction and allows implicit conversion
8586
* Calls T_DestructionPolicy::copy on copy which should return the id to store
@@ -89,7 +90,7 @@ namespace splash
8990
struct H5IdWrapper: public T_DestructionPolicy<hid_t>
9091
{
9192
typedef T_DestructionPolicy<hid_t> DestructionPolicy;
92-
93+
9394
H5IdWrapper(): id_(-1){}
9495
explicit H5IdWrapper(hid_t id): id_(id){}
9596
H5IdWrapper(const H5IdWrapper& rhs): DestructionPolicy(rhs)
@@ -137,7 +138,7 @@ namespace splash
137138

138139
operator hid_t() const { return id_; }
139140
operator bool() const { return id_ >= 0; }
140-
141+
141142
friend void swap(H5IdWrapper& lhs, H5IdWrapper& rhs)
142143
{
143144
std::swap(lhs.id_, rhs.id_);

src/include/splash/core/splashMacros.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#ifndef SPLASH_MACROS_HPP
2424
#define SPLASH_MACROS_HPP
2525

26+
//! @TODO Add macro defines for ICC, XLC, PGI
27+
2628
// Mark a function as deprecated: `SPLASH_DEPRECATED("Use bar instead") void foo();`
2729
#ifdef __clang__
2830
# define SPLASH_DEPRECATED(msg) __attribute__((deprecated(msg)))
@@ -34,4 +36,21 @@
3436
# define SPLASH_DEPRECATED(msg)
3537
#endif
3638

39+
// Suppress a "unused variable" warning: `SPLASH_UNUSED static int i = 42;`
40+
#ifdef __clang__
41+
# define SPLASH_UNUSED __attribute__((unused))
42+
#elif defined(__GNUC__)
43+
# define SPLASH_UNUSED __attribute__((unused))
44+
#elif defined(_MSC_VER)
45+
# define SPLASH_UNUSED
46+
#elif defined(__xlc__)
47+
# define SPLASH_UNUSED __attribute__((unused))
48+
#elif defined(__INTEL_COMPILER)
49+
# define SPLASH_UNUSED
50+
#elif defined(__PGI)
51+
# define SPLASH_UNUSED
52+
#else
53+
# define SPLASH_UNUSED
54+
#endif
55+
3756
#endif /* SPLASH_MACROS_HPP */

0 commit comments

Comments
 (0)