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