Titan Core Initial Contribution
[deliverable/titan.core.git] / common / static_check.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef STATIC_CHECK_HH
9 #define STATIC_CHECK_HH
10
11 #ifdef __cplusplus
12
13 template<bool> struct CompileTimeError;
14 template<> struct CompileTimeError<true> {}; // false never defined
15
16 #define STATIC_ASSERT(expr) CompileTimeError<(expr) != 0>()
17
18 #else
19
20 #define STATIC_ASSERT(x) do { enum { assert_static_ = 1/(x) }; } while(0)
21
22 #endif
23
24 #define ENSURE_EQUAL(x, y) STATIC_ASSERT((int)(x) == (int)(y));
25
26 #endif
This page took 0.042532 seconds and 5 git commands to generate.