Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ANSI C standard of zsh



On 3/25/2024 19:32, Clinton Bunch wrote:
On 3/25/2024 18:47, Oliver Kiddle wrote:
Clinton Bunch wrote:
Here is my first cut at replacement wording for the first two paragraphs
of the C coding style section:
This looks good to me.

If you wish to use features not present in the ANSI C 99 standard, there are preprocessor macros to provide safe access to some of these.  Always
use the macros if you want to use these facilities.
I was trying to think how this reads to someone completely unfamiliar
with the zsh code and what macros we have that meet this description.
Autoconf detects mostly system library/OS features and the macros
related to that are either defined to 1 (or left undefined). So the
macros allow you to make the use of such features conditional. "provide
safe access" sounds more like a wrapper – I couldn't think of an
example but that's not to say there aren't any. The preprocessor macros
are for anything that isn't portable rather than a particular language
standard.

Oliver
I think what was intended was macros like _POSIX_C_SOURCE and _XOPEN_SOURCE and __STDC__.  The glibc man pages are littered with them.


If we're going to say Zsh expects C99 we should probably update autoconf to check for C99 (and set any options needed)

I've attached a patch for the trivial change needed.


diff --git a/configure.ac b/configure.ac
index 78621042d..5984b667e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -462,7 +462,7 @@ dnl We want these before the checks, so the checks can modify their values.
 test -z "${CFLAGS+set}"  && CFLAGS=  auto_cflags=1
 test -z "${LDFLAGS+set}" && LDFLAGS= auto_ldflags=1
 
-AC_PROG_CC
+AC_PROG_CC_C99
 
 dnl Check for large file support.
 


Messages sorted by: Reverse Date, Date, Thread, Author