Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_DebugDefaultAsserts.hpp
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TEUCHOS_DEBUG_DEFAULT_ASSERTS_HPP
11#define TEUCHOS_DEBUG_DEFAULT_ASSERTS_HPP
12
13
14#include "Teuchos_Assert.hpp"
15
16
17#ifdef TEUCHOS_DEBUG
18#define TEUCHOS_SWITCH_DEFAULT_DEBUG_ASSERT() default: TEUCHOS_TEST_FOR_EXCEPT(true)
19#else
27#define TEUCHOS_SWITCH_DEFAULT_DEBUG_ASSERT()
28#endif
29
30// NOTE: Some explaination for the above TEUCHOS_SWITCH_DEFAULT_DEBUG_ASSERT()
31// macro:
32//
33// In a debug build where default: throws always, we can't have a follow-up
34// break statement or some compilers (e.g. NVCC) will (correctly) complain
35// that the 'break' statement is unreachable. Older compilers did not do
36// this. However, in a non-debug build, you want to not even put in a
37// 'default:' block. That way, if all of the enum values are not covered,
38// then must compilers will issue a warning about that and we want to see that
39// warning in a non-debug build.
40
41#ifdef TEUCHOS_DEBUG
42#define TEUCHOS_IF_ELSE_DEBUG_ASSERT() else { TEUCHOS_TEST_FOR_EXCEPT(true); }
43#else
51#define TEUCHOS_IF_ELSE_DEBUG_ASSERT() else {}
52#endif
53
54
55#endif // TEUCHOS_DEBUG_DEFAULT_ASSERTS_HPP