Discussion:
c99 support
Andy Wingo
2018-06-23 20:12:39 UTC
Permalink
Hi,

Is there anyone who compiles Guile with a compiler that does not support
C99? If so, please give platform and compiler.

I think my questions are limited to, in decreasing order of importance:

* Is there any system that we target that doesn't have C99 stdint.h
and stddef.h ?

* Is there any system that we target that doesn't support C99 inline
functions?

* C99 mixed decls and statements?

* C99 one-line comments (// foo) ?

* C99 compound literals? ((struct x) { 1, 2 }) ?

* stdbool.h

I would like to use C99 inside Guile, and I want to eventually replace
scm_t_uint8 with uint8_t.

Thanks,

Andy
Chris Vine
2018-06-24 00:00:43 UTC
Permalink
On Sat, 23 Jun 2018 22:12:39 +0200
Post by Andy Wingo
Hi,
Is there anyone who compiles Guile with a compiler that does not support
C99? If so, please give platform and compiler.
* Is there any system that we target that doesn't have C99 stdint.h
and stddef.h ?
* Is there any system that we target that doesn't support C99 inline
functions?
* C99 mixed decls and statements?
* C99 one-line comments (// foo) ?
* C99 compound literals? ((struct x) { 1, 2 }) ?
* stdbool.h
I would like to use C99 inside Guile, and I want to eventually replace
scm_t_uint8 with uint8_t.
I include guile headers in C++11 code. These C99 features seem to
be in current C++ (uint8_t is definitely supported if available on
the platform), except that my earlier assumption that compound literals
were in C++11 was wrong. They do work, but that's because they are a
supported gcc, clang and MSVC extension in C++. That's decent coverage
though.

Although stdbool.h exists in C++11, its contents are signficantly
reduced in scope because bool is separately supported in C++. The
definitions of bool are different in C99 and C++ - it is an integer type
plus macro in C99 - which might cause problems if the sizes of bool in
C++ and C99 are different. It would be a very poor implementation which
does this, but stdbool.h may be best avoided in a guile header file.

This is not relevant if you are only including C99 features in
implementation (*.c) files. That will always work OK.

Chris
Arne Babenhauserheide
2018-06-24 09:13:21 UTC
Permalink
Post by Chris Vine
On Sat, 23 Jun 2018 22:12:39 +0200
Post by Andy Wingo
Hi,
Is there anyone who compiles Guile with a compiler that does not support
C99? If so, please give platform and compiler.
* Is there any system that we target that doesn't have C99 stdint.h
and stddef.h ?
* Is there any system that we target that doesn't support C99 inline
functions?
* C99 mixed decls and statements?
* C99 one-line comments (// foo) ?
* C99 compound literals? ((struct x) { 1, 2 }) ?
* stdbool.h
I would like to use C99 inside Guile, and I want to eventually replace
scm_t_uint8 with uint8_t.
I include guile headers in C++11 code. These C99 features seem to
be in current C++ (uint8_t is definitely supported if available on
the platform), except that my earlier assumption that compound literals
were in C++11 was wrong. They do work, but that's because they are a
supported gcc, clang and MSVC extension in C++. That's decent coverage
though.
OpenIndiana requires GCC 4.4.4 to build, so if Guile should be usable
for Solaris/Illumos development, compatibility to that would be
important. 4.4.4 seems to already support major parts of C99, but I’m not
sure whether something is missing: https://gcc.gnu.org/c99status.html

https://wiki.illumos.org/display/illumos/How+To+Build+illumos#HowToBuildillumos-GCC

Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
Eli Zaretskii
2018-06-24 02:37:52 UTC
Permalink
Date: Sat, 23 Jun 2018 22:07:24 +0200
MS-Windows (MinGW) doesn't have a C99 compliant C library, although
quite a few of what's needed is present.
Hard to say :) I think my questions are limited to, in decreasing order
* Is there any system that we target that doesn't have C99 stdint.h
and stddef.h ?
* Is there any system that we target that doesn't support C99 inline
functions?
* C99 mixed decls and statements?
* C99 one-line comments (// foo) ?
* C99 compound literals? ((struct x) { 1, 2 }) ?
* stdbool.h
All of the above is available with reasonably recent versions of MinGW.
I assume MinGW uses GCC. What version? I see that the version 6 series
is available on mingw.org.
Current versions are 6 and 7, I have 5.3 installed on one of my
machines. All of them support what you mentioned.
Andy Wingo
2018-06-29 07:39:13 UTC
Permalink
Post by Andy Wingo
Is there anyone who compiles Guile with a compiler that does not support
C99? If so, please give platform and compiler.
* Is there any system that we target that doesn't have C99 stdint.h
and stddef.h ?
* Is there any system that we target that doesn't support C99 inline
functions?
* C99 mixed decls and statements?
* C99 one-line comments (// foo) ?
* C99 compound literals? ((struct x) { 1, 2 }) ?
* stdbool.h
I would like to use C99 inside Guile, and I want to eventually replace
scm_t_uint8 with uint8_t.
Thanks all for the responses. 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.

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.

If you make the change while targetting current Guile (2.2), then you'll
won't have deprecation warnings when 3.0 comes out.

Cheers,

Andy

Loading...