Program Listing for File macros.hpp
↰ Return to documentation for file (include/ecl/exceptions/macros.hpp
)
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef ECL_EXCEPTIONS_MACROS_HPP_
#define ECL_EXCEPTIONS_MACROS_HPP_
/*****************************************************************************
** Includes
*****************************************************************************/
#include <ecl/config/macros.hpp>
#include <ecl/config/ecl.hpp>
/*****************************************************************************
** Declspecs
*****************************************************************************/
/*
* Import/exports symbols for the library
*/
#ifdef ECL_HAS_SHARED_LIBS // ecl is being built around shared libraries
#ifdef ecl_exceptions_EXPORTS // we are building a shared lib/dll
#define ecl_exceptions_PUBLIC ECL_HELPER_EXPORT
#else // we are using shared lib/dll
#define ecl_exceptions_PUBLIC ECL_HELPER_IMPORT
#endif
#define ecl_exceptions_LOCAL ECL_HELPERS_LOCAL
#else // ecl is being built around static libraries
#define ecl_exceptions_PUBLIC
#define ecl_exceptions_LOCAL
#endif
/*****************************************************************************
** Macros [ecl_throw]
*****************************************************************************/
#if defined(ECL_DISABLE_EXCEPTIONS)
#define ecl_throw(exception) ((void)0)
#define ecl_try if(true)
#define ecl_catch(exception) else
#else
#define ecl_throw(exception) throw exception;
#define ecl_try try
#define ecl_catch(exception) catch(exception)
#endif
/*****************************************************************************
** Macros [ecl_assert_throw, ecl_debug_throw]
*****************************************************************************/
/* Some bad logic here - release can still mean we use some exceptions */
#if defined(NDEBUG) || defined(ECL_NDEBUG) || defined(ECL_DISABLE_EXCEPTIONS)
#define ecl_assert_throw(expression,exception) ((void)0)
#define ecl_debug_throw(exception) ((void)0)
#define ecl_debug_try if(true)
#define ecl_debug_catch(exception) else // TODO - this is useles, you can't do ecl_debug_catch(Exception &e) { std::cout << e.what() << std::endl; } in release mode
#else
#define ECL_HAS_EXCEPTIONS
#define ecl_assert_throw(expression,exception) if ( !(expression) ) { throw exception; }
#define ecl_debug_throw(exception) throw exception;
#define ecl_debug_try try
#define ecl_debug_catch(exception) catch(exception)
#endif
#endif /* ECL_EXCEPTIONS_MACROS_HPP_ */