Re: PG 17.2 compilation fails with -std=c11 on mac

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Lakshmi Narayana Velayudam <dev(dot)narayana(dot)v(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: PG 17.2 compilation fails with -std=c11 on mac
Date: 2025-05-16 15:42:23
Message-ID: 37369.1747410143@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Lakshmi Narayana Velayudam <dev(dot)narayana(dot)v(at)gmail(dot)com> writes:
> When I trying to compiling postgres 17.2 with -std=c11 I am getting the
> below error on mac

> explicit_bzero.c:22:9: error: call to undeclared function 'memset_s'; ISO
> C99 and later do not support implicit function declarations
> [-Wimplicit-function-declaration]

Yeah, I can reproduce that. After some digging, I see that
the problem is explained by "man memset_s":

SYNOPSIS

#define __STDC_WANT_LIB_EXT1__ 1

#include <string.h>

errno_t
memset_s(void *s, rsize_t smax, int c, rsize_t n);

We lack that #define, which results in <string.h> not supplying
the declaration. AFAICT the requirement for this is in the C11
standard, this is not just Apple doing something weird.

(I did not figure out how come the code compiles without -std=c11.)

Aside from this compilation error, we're probably failing to use
memset_s on some platforms where it's available, for lack of
the #define in our configure/meson probes. I know how to fix
that in configure, but I'm less clear on how nonstandard probes
work in meson --- any help there?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-05-16 15:50:14 Re: Align wording on copyright organization
Previous Message Fujii Masao 2025-05-16 15:40:53 Make wal_receiver_timeout configurable per subscription