The R Project SVN R

Rev

Rev 88163 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7727 ripley 1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
87740 ripley 3
 *  Copyright (C) 1998-2025   The R Core Team
7727 ripley 4
 *
71657 plummer 5
 *  This header file is free software; you can redistribute it and/or modify
12778 pd 6
 *  it under the terms of the GNU Lesser General Public License as published by
7
 *  the Free Software Foundation; either version 2.1 of the License, or
7727 ripley 8
 *  (at your option) any later version.
9
 *
71657 plummer 10
 *  This file is part of R. R is distributed under the terms of the
11
 *  GNU General Public License, either Version 2, June 1991 or Version 3,
12
 *  June 2007. See doc/COPYRIGHTS for details of the copyright status of R.
13
 *
7727 ripley 14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12778 pd 17
 *  GNU Lesser General Public License for more details.
7727 ripley 18
 *
12778 pd 19
 *  You should have received a copy of the GNU Lesser General Public License
42308 ripley 20
 *  along with this program; if not, a copy is available at
68949 ripley 21
 *  https://www.R-project.org/Licenses/
7727 ripley 22
 */
23
 
86515 luke 24
/* Included by R.h: Part of the API. */
60253 ripley 25
 
34746 ripley 26
#ifndef R_ERROR_H_
27
#define R_ERROR_H_
7727 ripley 28
 
87911 ripley 29
#include <R_ext/Print.h> // for R_PRINTF_FORMAT
85640 kalibera 30
 
11211 ripley 31
#ifdef  __cplusplus
32
extern "C" {
33
#endif
34
 
87751 ripley 35
/*
36
 * As this is sometimes an attribute, it should precede 'static' in a
37
 * function declaration.
88163 ripley 38
 * gcc 15 requires it to precede 'attribute_hidden'.
87751 ripley 39
 * OTOH, '_Noreturn' is an obsolescent (in C23) function specifier.
40
 */
83513 ripley 41
#if defined NORET
87740 ripley 42
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202301L)
88163 ripley 43
// gcc 15 LLVM clang 19- and Apple clang 17
83513 ripley 44
# define NORET [[noreturn]]
45
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201102L
46
# define NORET _Noreturn
47
#elif defined(__GNUC__) && __GNUC__ >= 3
87758 ripley 48
// All platforms these days should be using C >= 11 but perhaps used for C++
83513 ripley 49
# define NORET __attribute__((noreturn))
62363 ripley 50
#else
87758 ripley 51
// C++ and legacy
83513 ripley 52
# define NORET
62363 ripley 53
#endif
54
 
87911 ripley 55
#ifdef  __cplusplus
56
// Only supported in C++ >= 11, but that is all current R supports
57
// Defining NORET caused conflict in many C++-using packages
58
[[noreturn]] void Rf_error(const char *, ...) R_PRINTF_FORMAT(1, 2);
59
 
60
[[noreturn]] void UNIMPLEMENTED(const char *);
89135 luke 61
#ifdef USE_BASE_R_SUPPORT
87911 ripley 62
[[noreturn]] void WrongArgCount(const char *);
89135 luke 63
#endif
87911 ripley 64
#else
85640 kalibera 65
NORET void Rf_error(const char *, ...) R_PRINTF_FORMAT(1, 2);
85619 kalibera 66
 
83452 ripley 67
NORET void UNIMPLEMENTED(const char *);
89135 luke 68
#ifdef USE_BASE_R_SUPPORT
83452 ripley 69
NORET void WrongArgCount(const char *);
87911 ripley 70
#endif
89135 luke 71
#endif
67181 luke 72
 
87058 kalibera 73
void Rf_warning(const char *, ...) R_PRINTF_FORMAT(1,2);
85619 kalibera 74
 
87058 kalibera 75
void R_ShowMessage(const char *s);
7727 ripley 76
 
88116 hornik 77
/* xerbla is a C function intended to be called from Fortran.
87758 ripley 78
 * which forerly had a C declaration here.
79
 *
87122 ripley 80
 * It wraps Rf_error, so use that directtly from C/C++
81
*/
86984 maechler 82
 
11211 ripley 83
#ifdef  __cplusplus
84
}
7727 ripley 85
#endif
11211 ripley 86
 
22931 ripley 87
#ifndef R_NO_REMAP
85946 ripley 88
#define error Rf_error
22931 ripley 89
#define warning Rf_warning
90
#endif
91
 
92
 
34746 ripley 93
#endif /* R_ERROR_H_ */