curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: C99

From: Christoph M. Becker via curl-library <curl-library_at_lists.haxx.se>
Date: Tue, 20 Sep 2022 11:53:44 +0200

Hi!

On 20.09.2022 at 11:24, Daniel Stenberg via curl-library wrote:

> New mail thread to make this topic more visible. The idea of switching
> to C99 as the base level for curl code when we go version 8 (March 2023)
> is attractive to me. I figure compilers have had some time to get
> compliant and find widespread use by now!
>
> I added a PR just now to (primarly as a test) enforce C89 on the code
> when gcc is used, and it shows that we are already a bit sloppy in C89
> compliance in several areas of our code base:
> https://github.com/curl/curl/pull/9542
>
> But what does "going C99" mean for us? The C99 standard brought a whole
> busload of different new features to the language compared to C89, and
> some of them are:
>
>  — `//` comments
>  — `__func__` predefined identifer
>  — boolean type in `<stdbool.h>`
>  — designated struct initializers
>  — empty macro arguments
>  — extended integer types in `<inttypes.h>` and `<stdint.h>`
>  — fexible array members (zero size arrays)
>  — inline functions
>  — integer constant type rules
>  — mixed declarations and code
>  — the `long long` type and library functions
>  — the `snprintf()` family of functions
>  — trailing comma allowed in enum declaration
>  — vararg macros
>  — variable-length arrays
>
> I am not entirely convinced we want to go all-in and totally crazy on
> all these fronts immediately, and I think having an idea what we want in
> terms of code style is a good idea to have thought about before the
> flood gates open.
>
> At the same time, if we accept C99 it will be hard to enforce
> restrictions with compilers and checksrc certainly will not stop most of
> the things in that list (the //-comments perhaps being the single
> exception).

In my opinion, it makes sense to rely on some of the newer language
capabilities, but note that MSVC does not support all required language
features of C99 (only C11 and C17 are supported by recent versions).
This means in particular that variable length arrays are not supported
(and likely never will). More details are available at
<https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170>.

--
Christoph M. Becker
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2022-09-20