Skip to content

Commit a928176

Browse files
author
ripley
committed
add comments, most inspired by SM's experience on Alpine Linux/musl
git-svn-id: https://svn.r-project.org/R/trunk@87495 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 78782ce commit a928176

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

doc/manual/R-exts.texi

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5033,14 +5033,17 @@ POSIX and not supported on all the platforms @R{} is used on.
50335033
The variable @samp{OSTYPE} is shell-specific and its values are
50345034
rather unpredictable and may include a version such as
50355035
@samp{darwin19.0}: @command{`uname`} is often what is intended (with
5036-
common values @samp{Darwin}, @samp{Linux} and @samp{SunOS}).
5036+
common values @samp{Darwin} and @samp{Linux}).
50375037

50385038
On macOS which shell @file{/bin/sh} invokes is user- and
50395039
platform-dependent: it might be @command{bash} version 3.2,
50405040
@command{dash} or @command{zsh} (for new accounts it is @command{zsh},
50415041
for accounts ported from Mojave or earlier it is usually
50425042
@command{bash}).
50435043

5044+
It is not portable to specify @command{bash} as the shell let alone a
5045+
specific path such as @file{/bin/bash}.
5046+
50445047
@item
50455048
@R{} is not built by default as a shared library on non-Windows
50465049
platforms (although it commonly is on macOS to support the GUI), so
@@ -5910,6 +5913,12 @@ before @emph{any} headers. (@code{strdup}, @code{strncasecmp} and
59105913
@code{strnlen} are such functions -- there were several older platforms
59115914
which did not have the POSIX 2008 function @code{strnlen}.)
59125915

5916+
`Linux' is not a well-defined operating system: it is a kernel plus a
5917+
collection of components. Most distributions use @code{glibc} to
5918+
provide most of the C headers and run-time library, but others, notably
5919+
Alpine Linux, use other implementations such as @code{musl} --- see
5920+
@uref{https://wiki.musl-libc.org/functional-differences-from-glibc.html}.
5921+
59135922
However, some common errors are worth pointing out here. It can be
59145923
helpful to look up functions at
59155924
@uref{https://cplusplus.com/reference/} or
@@ -6023,7 +6032,8 @@ included by other headers on Linux and Windows but not macOS.)
60236032
these in other headers. @command{g++}@tie{}13 requires the
60246033
explicit inclusion of @code{<cstdint>} for types such as @code{uint32_t}
60256034
which was previously included implicitly. (For more such, see
6026-
@uref{https://gcc.gnu.org/gcc-13/porting_to.html}.)
6035+
@uref{https://gcc.gnu.org/gcc-13/porting_to.html}.) There are further
6036+
instances of this in @command{g++}@tie{}15: see @uref{https://gcc.gnu.org/gcc-13/porting_to.html}.
60276037

60286038
Note that @code{malloc}, @code{calloc}, @code{realloc} and @code{free}
60296039
are defined by C99 in the header @file{stdlib.h} and (in the
@@ -6036,6 +6046,9 @@ say that is declared in headers @code{unistd.h} and @code{sys/types.h},
60366046
and the latter is often included indirectly by other headers on some
60376047
but not all systems.
60386048

6049+
POSIX mandates the header @code{unistd.h}: most but not all OSes supply
6050+
header @code{sys/unistd.h} as a wrapper, so this should not be used.
6051+
60396052
Similarly for constants: for example @code{SIZE_MAX} is defined in
60406053
@code{stdint.h} alongside @code{size_t}.
60416054

@@ -6045,6 +6058,10 @@ and often @acronym{CRAN} submissions attempt to use @file{endian.h}.
60456058
The latter is a @code{glibc} extension: some OSes have
60466059
@file{machine/endian.h} or @file{sys/endian.h} but some have neither.
60476060
@c macOS has machine/endian.h. Solaris had none.
6061+
Header @file{execinfo.h} is only available on a few OSes: formwrly nor
6062+
in MacOS nor Solaris, and currently not on Linux systems (such as Aloine
6063+
Linux)using @code{musl}. Nor is header @file{fpu_control.h} avaialble
6064+
on macOS nor @code{musl}.
60486065

60496066
@item
60506067
Use @code{#include "my.h"} not @code{#include <my.h>} for headers in

0 commit comments

Comments
 (0)