/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright 2010-2019 Danny Robson */ #pragma once /////////////////////////////////////////////////////////////////////////////// // it is fractionally easier to define a constexpr variable which can be used // in constexpr-if to enable/disable some codepaths rather than deal with // macros in some scenarios. eg, templates are complicated enough without // (more) macros. #if !defined(NDEBUG) constexpr bool debug_enabled = true; constexpr bool assertions_enabled = true; #else constexpr bool debug_enabled = false; constexpr bool assertions_enabled = false; #endif ///---------------------------------------------------------------------------- /// enable some code only if assertions are enabled /// /// explicitly does not use constexpr if to remove the code as some paths may /// refer to variables which do not always exist, and current compiler /// implementations are a little picky here. #ifndef NDEBUG #define DEBUG_ONLY(X) do { X; } while (0) #else #define DEBUG_ONLY(X) do { ; } while (0) #endif /////////////////////////////////////////////////////////////////////////////// #define EXIT_XSUCCESS 0 #define EXIT_XSKIP 77 #define EXIT_XHARD_ERROR 99