Skip to content

Commit 44aceec

Browse files
author
ripley
committed
make sure Boolean.h finds bool type
git-svn-id: https://svn.r-project.org/R/trunk@87842 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 42ab1b5 commit 44aceec

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

doc/NEWS.Rd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,12 @@
348348
unaware of any such platform).
349349
350350
\item There is a new function \code{asRboolean}, a variannt of
351-
\code{asLogical} more suitable to converting logical arguments to
351+
\code{asLogical} more suited to converting logical arguments to
352352
\code{Rboolean}.
353+
354+
\item Header \file{R_ext/Boolean.h} now ensures a \code{bool} type
355+
is available either as a keyword (C23 and C++) or by including the
356+
C99 header \file{stdbool.h}.
353357
}
354358
}
355359

src/include/R_ext/Boolean.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@
2929
#undef FALSE
3030
#undef TRUE
3131

32+
/* Ensuure a 'bool' type is available. We could use
33+
__bool_true_false_are_defined,
34+
but that was declared obsolescent in C23.
35+
*/
36+
#if defined __STDC_VERSION__ && __STDC_VERSION__ > 202000L
37+
// C23 so bool is a keyword
38+
#elif defined __cplusplus
39+
// part of C++ >= 11, which is all R supports.
40+
#else
41+
# include <stdbool.h>
42+
// stdbool.h is C99, so available everywhere.
43+
#endif
44+
3245
#include <Rconfig.h> /* for HAVE_ENUM_BASE_TYPE */
3346
/*
3447
Setting the underlying aka base type is supported in C23, C++11

0 commit comments

Comments
 (0)