[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: c99 support
Re: c99 support
Fri, 29 Jun 2018 11:10:27 +0100
On Fri, 29 Jun 2018 10:39:33 +0200
Hans Åberg <address@hidden> wrote:
> > On 29 Jun 2018, at 09:39, Andy Wingo <address@hidden> wrote:
> > It would seem that the first four
> > features of C99 are OK for all platforms that we target, with the
> > following caveats:
> > * We should avoid using C++ keywords (e.g. throw) in Guile API files.
> > * We might want to avoid mixed decls and statements in inline functions
> > in Guile API files.
> > We should probably avoid stdbool.h and compound literals, for C++
> > reasons.
> You might make a separate C++ header: It turned out too complicated for Bison
> to maintain the compile as C++ generated C parser.
> > In Guile 3.0 (master branch), the types "scm_t_uint8" and so on are now
> > deprecated. My recommendation is that all users switch to use
> > e.g. "uint8_t", "ptrdiff_t", etc from <stdint.h> instead of the
> > scm_t_uint8, etc definitions that they are now using. The definitions
> > are compatible on all systems, AFAIU, and on GNU, scm_t_uint8 has long
> > been a simple typedef for uint8_t.
> For C++, these are only optional, cf. , as they require no padding. So an
> alternative is to typedef the obligatory int_fast<2^k>_t types, perhaps
> leaving the API unchanged.
> 1. https://en.cppreference.com/w/cpp/types/integer
The fixed size integer types are optional in C99/11 also, depending on
whether the platform provides a fixed size integer of the type in
question without padding and (for negative integers) a two's complement
representation. If, say, uint8_t is available in stdint.h for C, it
will be available for C++. §21.4.1/2 of C++17 makes this even more
explicit: "The [cstdint] header defines all types and macros the
same as the C standard library header <stdint.h>".
I imagine guile will not run on any platform that does not support 8
and 32 bit fixed size integers.