mirror of
https://github.com/google/benchmark.git
synced 2025-03-26 12:04:49 +08:00
CHECK_* are now private and used internally in the library. The test uses have been replaced with asserts. Fixes #62.
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
#ifndef BENCHMARK_MACROS_H_
|
|
#define BENCHMARK_MACROS_H_
|
|
|
|
#include <assert.h>
|
|
#include <stddef.h>
|
|
|
|
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
|
TypeName(const TypeName&); \
|
|
void operator=(const TypeName&);
|
|
|
|
// The arraysize(arr) macro returns the # of elements in an array arr.
|
|
// The expression is a compile-time constant, and therefore can be
|
|
// used in defining new arrays, for example. If you use arraysize on
|
|
// a pointer by mistake, you will get a compile-time error.
|
|
//
|
|
// One caveat is that, for C++03, arraysize() doesn't accept any array of
|
|
// an anonymous type or a type defined inside a function. In these rare
|
|
// cases, you have to use the unsafe ARRAYSIZE() macro below. This is
|
|
// due to a limitation in C++03's template system. The limitation has
|
|
// been removed in C++11.
|
|
|
|
// This template function declaration is used in defining arraysize.
|
|
// Note that the function doesn't need an implementation, as we only
|
|
// use its type.
|
|
template <typename T, size_t N>
|
|
char (&ArraySizeHelper(T (&array)[N]))[N];
|
|
|
|
// That gcc wants both of these prototypes seems mysterious. VC, for
|
|
// its part, can't decide which to use (another mystery). Matching of
|
|
// template overloads: the final frontier.
|
|
#ifndef COMPILER_MSVC
|
|
template <typename T, size_t N>
|
|
char (&ArraySizeHelper(const T (&array)[N]))[N];
|
|
#endif
|
|
|
|
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
|
|
|
|
//
|
|
// Prevent the compiler from complaining about or optimizing away variables
|
|
// that appear unused.
|
|
#define ATTRIBUTE_UNUSED __attribute__((unused))
|
|
|
|
//
|
|
// For functions we want to force inline or not inline.
|
|
// Introduced in gcc 3.1.
|
|
#define ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
|
|
#define HAVE_ATTRIBUTE_ALWAYS_INLINE 1
|
|
#define ATTRIBUTE_NOINLINE __attribute__((noinline))
|
|
#define HAVE_ATTRIBUTE_NOINLINE 1
|
|
|
|
#endif // BENCHMARK_MACROS_H_
|