The R Project SVN R

Rev

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

Rev Author Line No. Line
11499 ripley 1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
89450 ripley 3
 *  Copyright (C) 2000, 2026 The R Core Team.
11499 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
11499 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
 *
11499 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.
11499 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/
11499 ripley 22
 */
23
 
87679 ripley 24
/* Included by R.h: API */
60256 ripley 25
 
10589 maechler 26
#ifndef R_EXT_BOOLEAN_H_
27
#define R_EXT_BOOLEAN_H_
88052 ripley 28
#if !defined(R_INCLUDE_BOOLEAN_H) || R_INCLUDE_BOOLEAN_H
10589 maechler 29
 
87951 ripley 30
// NB: there is a version of this in Rmath.h0[.in]
31
 
10589 maechler 32
#undef FALSE
33
#undef TRUE
11211 ripley 34
 
87842 ripley 35
/* Ensuure a 'bool' type is available.  We could use
36
   __bool_true_false_are_defined, 
37
   but that was declared obsolescent in C23.
38
*/
39
#if defined __STDC_VERSION__ && __STDC_VERSION__ > 202000L
40
// C23 so bool is a keyword
41
#elif defined __cplusplus
42
// part of C++ >= 11, which is all R supports.
43
#else
44
# include <stdbool.h>
45
// stdbool.h is C99, so available everywhere.
46
#endif
47
 
87798 ripley 48
#include <Rconfig.h> /* for HAVE_ENUM_BASE_TYPE */
49
/*
50
  Setting the underlying aka base type is supported in C23, C++11 
87835 ripley 51
  and some C compilers based on clang and some versions of GCC.
87798 ripley 52
  What matters here is the C compiler used to build R.
53
 */
87681 ripley 54
#ifdef  __cplusplus
87679 ripley 55
extern "C" {
87681 ripley 56
#endif
87798 ripley 57
#ifdef HAVE_ENUM_BASE_TYPE
89450 ripley 58
// Apple clang 17 warns even in C23 mode: gcc warns about #pragma clang
59
// LLVM clang no longer warns.
60
// Apple clang 21 no longer has that warning.
61
# if defined  __APPLE__ && defined __clang__ && __clang_major__ < 21
87798 ripley 62
#  pragma clang diagnostic push
63
#  pragma clang diagnostic ignored "-Wfixed-enum-extension"
64
# endif
65
 
66
  typedef enum :int { FALSE = 0, TRUE } Rboolean;  // so NOT NA
67
 
89450 ripley 68
# if defined  __APPLE__ && defined __clang__ && __clang_major__ < 21
87798 ripley 69
#  pragma clang diagnostic pop
70
# endif
71
#else
87684 ripley 72
    typedef enum { FALSE = 0, TRUE } Rboolean;  // so NOT NA
87798 ripley 73
#endif
87681 ripley 74
#ifdef  __cplusplus
11211 ripley 75
}
10590 maechler 76
#endif
11211 ripley 77
 
88052 ripley 78
#else
79
/* The Rbolean type is used in too many R headers to condition them
80
 * all.  However, people defining R_INCLUDE_BOOLEAN_H=0 should not be
81
 * using it in their own code, and its base type is expected to be int
82
 * (and guaranteed to be on most platforms as from R 4.5.0). */
83
 
84
    typedef Rboolean int;
85
#endif /* R_INCLUDE_BOOLEAN_H = 0 */
11211 ripley 86
#endif /* R_EXT_BOOLEAN_H_ */