src/core/fatal-error.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 3182 61fe7fe81ebd
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     3  * Copyright (c) 2006 INRIA
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License version 2 as
     7  * published by the Free Software Foundation;
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    17  *
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    19  */
    20 #ifndef FATAL_ERROR_H
    21 #define FATAL_ERROR_H
    22 
    23 #include <iostream>
    24 
    25 /**
    26  * \ingroup debugging
    27  * \brief fatal error handling
    28  *
    29  * \param msg message to output when this macro is hit.
    30  *
    31  * When this macro is hit at runtime, the user-specified 
    32  * error message is output and the program is halted by
    33  * dereferencing a null pointer. This macro is enabled 
    34  * unconditionally in all builds, including debug and 
    35  * optimized builds.
    36  */
    37 #define NS_FATAL_ERROR(msg)				\
    38   do                                                    \
    39     {                                                   \
    40       std::cerr << msg << std::endl;			\
    41       int *a = 0;                                       \
    42       *a = 0;                                           \
    43     }                                                   \
    44   while (false)
    45 
    46 
    47 #endif /* FATAL_ERROR_H */