Mercury
na_error.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Argonne National Laboratory, Department of Energy,
3  *                    UChicago Argonne, LLC and The HDF Group.
4  * All rights reserved.
5  *
6  * The full copyright notice, including terms governing use, modification,
7  * and redistribution, is contained in the COPYING file that can be
8  * found at the root of the source code distribution tree.
9  */
10 
11 #ifndef NA_ERROR_H
12 #define NA_ERROR_H
13 
14 #include "na_config.h"
15 
16 /* For compatibility */
17 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ < 199901L)
18  #if defined(__GNUC__) && (__GNUC__ >= 2)
19  #define __func__ __FUNCTION__
20  #else
21  #define __func__ "<unknown>"
22  #endif
23 #elif defined(_WIN32)
24  #define __func__ __FUNCTION__
25 #endif
26 
27 /* Default error macro */
28 #ifdef NA_HAS_VERBOSE_ERROR
29  #include <stdio.h>
30  #define NA_LOG_ERROR(...) do { \
31  fprintf(stderr, "NA: Error in %s:%d\n", __FILE__, __LINE__); \
32  fprintf(stderr, " # %s(): ", __func__); \
33  fprintf(stderr, __VA_ARGS__); \
34  fprintf(stderr, "\n"); \
35  } while (0)
36  #define NA_LOG_DEBUG(...) do { \
37  fprintf(stdout, "NA: in %s:%d\n", __FILE__, __LINE__); \
38  fprintf(stdout, " # %s(): ", __func__); \
39  fprintf(stdout, __VA_ARGS__); \
40  fprintf(stdout, "\n"); \
41  } while (0)
42  #define NA_LOG_WARNING(...) do { \
43  fprintf(stdout, "NA: Warning in %s:%d\n", __FILE__, __LINE__); \
44  fprintf(stdout, " # %s(): ", __func__); \
45  fprintf(stdout, __VA_ARGS__); \
46  fprintf(stdout, "\n"); \
47  } while (0)
48 #else
49  #define NA_LOG_ERROR
50  #define NA_LOG_DEBUG
51  #define NA_LOG_WARNING
52 #endif
53 
54 #endif /* NA_ERROR_H */