public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: M Hickford <mirth.hickford@gmail•com>
To: Patrick Steinhardt <ps@pks•im>, git@vger•kernel.org
Cc: Evan Martin <evan.martin@gmail•com>, Eli Schwartz <eschwartz@gentoo•org>
Subject: Re: [PATCH 8/9] meson: fix compilation with Visual Studio
Date: Mon, 13 Jan 2025 21:12:21 +0000	[thread overview]
Message-ID: <6df239ab-eb04-41d0-898d-7cafe925b13a@gmail.com> (raw)
In-Reply-To: <20250113-b4-pks-meson-additions-v1-8-97f6a93f691d@pks.im>

On 2025-01-13 08:33, Patrick Steinhardt wrote:
> The Visual Studio compiler defaults to C89 unless explicitly asked to
> use a different version of the C standard. We don't specify any C
> standard at all though in our Meson build, and consequently compiling
> Git fails:
> 
>      ...\git\git-compat-util.h(14): fatal error C1189: #error:  "Required C99 support is in a test phase.  Please see git-compat-util.h for more details."
> 
> Fix the issue by specifying the project's C standard. Funny enough,
> specifying C99 does not work because apparently, `__STDC_VERSION__` is
> not getting defined in that version at all. Instead, we have to specify
> C11 as the project's C standard, which is also done in our CMake build
> instructions.
> 
> We don't want to generally enforce C11 though, as our requiremets only
> state that a C99 compiler is required. In fact, we don't even require
> plain C99, but rather the GNU variant thereof.
> 
> Meson allows us to handle this case rather easily by specifying
> "gnu99,c11", which will cause it to fall back to C11 in case GNU C99 is
> unsupported. This feature has only been introduced with Meson 1.3.0
> though, and we support 0.61.0 and newer. In case we use such an oldish
> version though we fall back to requiring GNU99 unconditionally. This
> means that Windows essentially requires Meson 1.3.0 and newer when using
> Visual Studio, but I doubt that this is ever going to be a real problem.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks•im>

Thanks. This fixes the problem for me.

Tested-by: M Hickford <mirth.hickford@gmail•com>

> ---
>   meson.build | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index cb352ce6fd50616e3281a776104692c5b2bfa5b2..831da1d43cafe85a8c9ac872e141476adbc08188 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -171,6 +171,14 @@
>   project('git', 'c',
>     meson_version: '>=0.61.0',
>     version: files('GIT-VERSION'),
> +  default_options: [
> +    # Git requires C99 with GNU extensions, which of course isn't supported by
> +    # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only
> +    # learned to define __STDC_VERSION__ with C11 and later. We thus require
> +    # GNU C99 and fall back to C11. Meson only learned to handle the fallback
> +    # with version 1.3.0, so on older versions we use GNU C99 unconditionally.
> +    'c_std=' + (meson.version().version_compare('>=1.3.0') ? 'gnu99,c11' : 'gnu99'),
> +  ]
>   )
>   
>   fs = import('fs')
> 


  reply	other threads:[~2025-01-13 21:12 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13  8:33 [PATCH 0/9] meson: a couple of additions Patrick Steinhardt
2025-01-13  8:33 ` [PATCH 1/9] GIT-VERSION-GEN: simplify computing the dirty marker Patrick Steinhardt
2025-01-13  8:33 ` [PATCH 2/9] GIT-VERSION-GEN: move default version into a separate file Patrick Steinhardt
2025-01-13 17:42   ` Junio C Hamano
2025-01-13 17:51     ` Eli Schwartz
2025-01-14  9:13       ` Patrick Steinhardt
2025-01-13  8:33 ` [PATCH 3/9] meson: fix dependencies for generated headers Patrick Steinhardt
2025-01-13  8:33 ` [PATCH 4/9] meson: wire up development environments Patrick Steinhardt
2025-01-13  8:33 ` [PATCH 5/9] meson: wire up generation of distribution archive Patrick Steinhardt
2025-01-13 17:55   ` Junio C Hamano
2025-01-14  9:14     ` Patrick Steinhardt
2025-01-13  8:33 ` [PATCH 6/9] meson: wire up fuzzers Patrick Steinhardt
2025-01-13 17:48   ` Junio C Hamano
2025-01-14 10:31     ` Patrick Steinhardt
2025-01-13  8:33 ` [PATCH 7/9] meson: make the CSPRNG backend configurable Patrick Steinhardt
2025-01-13  9:25   ` Patrick Steinhardt
2025-01-13 17:59   ` Junio C Hamano
2025-01-14  9:13     ` Patrick Steinhardt
2025-01-14 19:13       ` Junio C Hamano
2025-01-13  8:33 ` [PATCH 8/9] meson: fix compilation with Visual Studio Patrick Steinhardt
2025-01-13 21:12   ` M Hickford [this message]
2025-01-13  8:33 ` [PATCH 9/9] ci: wire up Visual Studio build with Meson Patrick Steinhardt
2025-01-14 11:56 ` [PATCH v2 00/11] meson: a couple of additions Patrick Steinhardt
2025-01-14 11:56   ` [PATCH v2 01/11] GIT-VERSION-GEN: simplify computing the dirty marker Patrick Steinhardt
2025-01-14 11:56   ` [PATCH v2 02/11] GIT-VERSION-GEN: allow running without input and output files Patrick Steinhardt
2025-01-21 13:16     ` Toon Claes
2025-01-14 11:56   ` [PATCH v2 03/11] meson: populate project version via GIT-VERSION-GEN Patrick Steinhardt
2025-01-21 13:13     ` Toon Claes
2025-01-14 11:56   ` [PATCH v2 04/11] meson: fix dependencies for generated headers Patrick Steinhardt
2025-01-14 11:56   ` [PATCH v2 05/11] meson: wire up development environments Patrick Steinhardt
2025-01-14 11:56   ` [PATCH v2 06/11] meson: wire up generation of distribution archive Patrick Steinhardt
2025-01-21 12:37     ` Toon Claes
2025-01-22 12:05       ` Patrick Steinhardt
2025-01-14 11:56   ` [PATCH v2 07/11] meson: wire up fuzzers Patrick Steinhardt
2025-01-14 11:56   ` [PATCH v2 08/11] meson: make the CSPRNG backend configurable Patrick Steinhardt
2025-01-14 11:56   ` [PATCH v2 09/11] meson: fix compilation with Visual Studio Patrick Steinhardt
2025-01-14 11:56   ` [PATCH v2 10/11] ci: raise error when Meson generates warnings Patrick Steinhardt
2025-01-21 12:59     ` Toon Claes
2025-01-14 11:56   ` [PATCH v2 11/11] ci: wire up Visual Studio build with Meson Patrick Steinhardt
2025-01-14 17:46   ` [PATCH v2 00/11] meson: a couple of additions Junio C Hamano
2025-01-22 12:05 ` [PATCH v3 " Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 01/11] GIT-VERSION-GEN: simplify computing the dirty marker Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 02/11] GIT-VERSION-GEN: allow running without input and output files Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 03/11] meson: populate project version via GIT-VERSION-GEN Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 04/11] meson: fix dependencies for generated headers Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 05/11] meson: wire up development environments Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 06/11] meson: wire up generation of distribution archive Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 07/11] meson: wire up fuzzers Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 08/11] meson: make the CSPRNG backend configurable Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 09/11] meson: fix compilation with Visual Studio Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 10/11] ci: raise error when Meson generates warnings Patrick Steinhardt
2025-01-22 12:05   ` [PATCH v3 11/11] ci: wire up Visual Studio build with Meson Patrick Steinhardt
2025-01-22 21:42   ` [PATCH v3 00/11] meson: a couple of additions Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6df239ab-eb04-41d0-898d-7cafe925b13a@gmail.com \
    --to=mirth.hickford@gmail$(echo .)com \
    --cc=eschwartz@gentoo$(echo .)org \
    --cc=evan.martin@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=ps@pks$(echo .)im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox