Flow123d  release_1.8.2-1603-g0109a2b
global_defs.h File Reference

Global macros to enhance readability and debugging, general constants. More...

#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "system/exc_common.hh"
#include "config.h"
#include "mpi.h"
#include "asserts.hh"

Go to the source code of this file.

Macros

#define INPUT_CHECK(i, ...)    do { if (!(i)) xprintf(UsrErr,__VA_ARGS__); } while (0)
 Debugging macros. More...
 
#define OLD_ASSERT(...)
 
#define OLD_WARN_ASSERT(...)
 
#define OLD_ASSERT_EQUAL(a, b)
 
#define OLD_ASSERT_LESS(a, b)
 
#define OLD_ASSERT_LE(a, b)
 
#define OLD_ASSERT_PTR(ptr)
 
#define _FEAL_ASSERT_A(x)   _FEAL_ASSERT_OP(x, B)
 
#define _FEAL_ASSERT_B(x)   _FEAL_ASSERT_OP(x, A)
 Internal clever macro B. More...
 
#define _FEAL_ASSERT_OP(x, next)   _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next
 Internal clever macro recursion. More...
 
#define FEAL_ASSERT(expr)
 Definition of assert for debug and release mode. More...
 
#define FEAL_DEBUG_ASSERT(expr)
 Definition of assert for debug mode only. More...
 
#define _FEAL_ASSERT_A(x)   _FEAL_ASSERT_OP(x, B)
 
#define _FEAL_ASSERT_B(x)   _FEAL_ASSERT_OP(x, A)
 Internal clever macro B. More...
 
#define _FEAL_ASSERT_OP(x, next)   _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next
 Internal clever macro recursion. More...
 
#define FEAL_ASSERT(expr)
 Definition of assert for debug and release mode. More...
 
#define FEAL_DEBUG_ASSERT(expr)
 Definition of assert for debug mode only. More...
 
#define ASSERT(expr)   FEAL_ASSERT( expr)
 Allow use shorter versions of macro names if these names is not used with external library. More...
 
#define DEBUG_ASSERT(expr)   FEAL_DEBUG_ASSERT( expr)
 
#define DBGMSG(...)
 
#define DBGCOUT(...)
 
#define DBGVAR(var)
 
#define FLOW123D_FORCE_LINK_IN_CHILD(x)   int force_link_##x = 0;
 
#define FLOW123D_FORCE_LINK_IN_PARENT(x)   extern int force_link_##x; void func_##x() { force_link_##x = 1; }
 

Detailed Description

Global macros to enhance readability and debugging, general constants.

 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Definition in file global_defs.h.

Macro Definition Documentation

#define _FEAL_ASSERT_A (   x)    _FEAL_ASSERT_OP(x, B)

Internal definitions of macros Internal clever macro A

Definition at line 167 of file global_defs.h.

#define _FEAL_ASSERT_A (   x)    _FEAL_ASSERT_OP(x, B)

Internal definitions of macros Internal clever macro A

Definition at line 167 of file global_defs.h.

#define _FEAL_ASSERT_B (   x)    _FEAL_ASSERT_OP(x, A)

Internal clever macro B.

Definition at line 169 of file global_defs.h.

#define _FEAL_ASSERT_B (   x)    _FEAL_ASSERT_OP(x, A)

Internal clever macro B.

Definition at line 169 of file global_defs.h.

#define _FEAL_ASSERT_OP (   x,
  next 
)    _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next

Internal clever macro recursion.

Definition at line 171 of file global_defs.h.

#define _FEAL_ASSERT_OP (   x,
  next 
)    _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next

Internal clever macro recursion.

Definition at line 171 of file global_defs.h.

#define ASSERT (   expr)    FEAL_ASSERT( expr)

Allow use shorter versions of macro names if these names is not used with external library.

Definition at line 195 of file global_defs.h.

#define DBGCOUT (   ...)

Definition at line 230 of file global_defs.h.

#define DBGMSG (   ...)

Definition at line 229 of file global_defs.h.

#define DBGVAR (   var)

Definition at line 231 of file global_defs.h.

#define DEBUG_ASSERT (   expr)    FEAL_DEBUG_ASSERT( expr)

Definition at line 198 of file global_defs.h.

#define FEAL_ASSERT (   expr)
Value:
if ( !(expr) ) \
feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A

Definition of assert for debug and release mode.

Definition at line 176 of file global_defs.h.

#define FEAL_ASSERT (   expr)
Value:
if ( !(expr) ) \
feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A

Definition of assert for debug and release mode.

Definition at line 176 of file global_defs.h.

#define FEAL_DEBUG_ASSERT (   expr)

Definition of assert for debug mode only.

Definition at line 186 of file global_defs.h.

#define FEAL_DEBUG_ASSERT (   expr)
Value:
if ( !(expr) ) \
feal::AssertNull()._FEAL_ASSERT_A

Definition of assert for debug mode only.

Definition at line 186 of file global_defs.h.

#define FLOW123D_FORCE_LINK_IN_CHILD (   x)    int force_link_##x = 0;

These macros are necessary in classes that contain Input::Type::Abstract (PARENT macro) and in classes contain descendant of this Abstract (CHILD macro) if these descendants are initialized through methods of Input::Factory class.

These macros are necessary for initializing of static variables in classes that contain descendants of parent Abstract.

Definition at line 246 of file global_defs.h.

#define FLOW123D_FORCE_LINK_IN_PARENT (   x)    extern int force_link_##x; void func_##x() { force_link_##x = 1; }

Definition at line 247 of file global_defs.h.

#define INPUT_CHECK (   i,
  ... 
)    do { if (!(i)) xprintf(UsrErr,__VA_ARGS__); } while (0)

Debugging macros.

The macro OLD_ASSERT has to be used for assertion tests. An error occures if given condition is violated. Macro accepts additional variables to print.

Example:

*  OLD_ASSERT( i<size , "Array X overflow: index %d >= alocated size %d.\n",i,size);
*  

The macro INPUT_CHECK should be used for assertions about user input. So they produce User Error instead of Program error.

The macro DBGMSG should be used for debugging messages, so they can be removed in production version.

OLD_WARN_ASSERT - can be used for consistency tests in debugging version.

Definition at line 51 of file global_defs.h.

#define OLD_ASSERT (   ...)

Actually there are following debugging switches FLOW123D_DEBUG_MESSAGES - use various debugging messages introduced by DBGMSG FLOW123D_DEBUG_ASSERTS - use assertion checks introduced by ASSERT FLOW123D_DEBUG_PROFILER - use profiling introduced by START_TIMER, END_TIMER

You can turn all off defining: FLOW123D_NODEBUG or turn all on defining: FLOW123D_DEBUG

FLOW123D_DEBUG overrides FLOW123D_NODEBUG

Definition at line 128 of file global_defs.h.

#define OLD_ASSERT_EQUAL (   a,
 
)

Definition at line 130 of file global_defs.h.

#define OLD_ASSERT_LE (   a,
 
)

Definition at line 132 of file global_defs.h.

#define OLD_ASSERT_LESS (   a,
 
)

Definition at line 131 of file global_defs.h.

#define OLD_ASSERT_PTR (   ptr)

Definition at line 133 of file global_defs.h.

#define OLD_WARN_ASSERT (   ...)

Definition at line 129 of file global_defs.h.