/*---------------------------------------------------------------------------* Project: Horizon File: util_StaticAssert.h Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 16675 $ *--------------------------------------------------------------------------- */ #ifndef NN_UTIL_UTIL_STATICASSERT_H_ #define NN_UTIL_UTIL_STATICASSERT_H_ #ifdef __cplusplus namespace nn { namespace util { template struct STATIC_ASSERTION_FAILURE; template <> struct STATIC_ASSERTION_FAILURE {}; namespace detail { template struct static_assert_test {}; } }} #define NN_UTIL_STATICASSERT_H_STRING_JOIN_(X, Y) NN_UTIL_STATICASSERT_H_STRING_JOIN1_(X, Y) #define NN_UTIL_STATICASSERT_H_STRING_JOIN1_(X, Y) X##Y /* Please see man pages for details */ #define NN_STATIC_ASSERT(B) typedef ::nn::util::detail::static_assert_test)> NN_UTIL_STATICASSERT_H_STRING_JOIN_(nn_util_static_assert_typedef_, __LINE__) /* Please see man pages for details */ #define NN_STATIC_ASSERT_IS_POD(T) typedef union { T NN_UTIL_STATICASSERT_H_STRING_JOIN_(nn_util_static_assert_is_pod_menber_, __LINE__); } NN_UTIL_STATICASSERT_H_STRING_JOIN_(nn_util_static_assert_is_pod_, __LINE__) #else // __cplusplus // #define NN_STATIC_ASSERT(expr) char NN_UTIL_STATICASSERT_H_STRING_JOIN_(nn_util_static_assert_dummy_, __LINE__)[(expr) ? 1 : -1] #define NN_STATIC_ASSERT(expr) void NN_UTIL_STATICASSERT_H_STRING_JOIN_##__FILE__##__LINE__(int arg[(expr) ? 1 : -1]) #define NN_STATIC_ASSERT_IS_POD(T) typedef void NN_UTIL_STATICASSERT_H_STRING_JOIN_(nn_util_static_assert_dummy_, __LINE__) #endif #define NN_COMPILER_ASSERT(x) NN_STATIC_ASSERT(x) #endif /* NN_UTIL_STATICASSERT_H_ */