From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: emacs-devel@gnu.org, eggert@cs.ucla.edu
Subject: Re: Using static_assert in Emacs?
Date: Thu, 18 Jul 2024 20:35:44 +0300 [thread overview]
Message-ID: <865xt2fvrj.fsf@gnu.org> (raw)
In-Reply-To: <CADwFkmkhuR_1DMNKgfVHsbuLsMDaTp+=O5msCXtQccKKgiajmg@mail.gmail.com> (message from Stefan Kangas on Thu, 18 Jul 2024 09:39:43 -0700)
> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Thu, 18 Jul 2024 09:39:43 -0700
> Cc: emacs-devel@gnu.org, eggert@cs.ucla.edu
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > We already have it in config.h, so we can use it. (Gnulib actually
> > uses it, see lib/*.c.)
>
> Good to know, thanks.
>
> > The real question is: where and how will that be useful?
>
> I'm looking at something like this, where the sizes are known at compile
> time:
>
> #define FOO "some text"
> static_assert (sizeof buf >= sizeof FOO);
> memcpy (buf, FOO, sizeof FOO);
If we have such code (do we?), and if there's a danger that someone
makes FOO longer but forgets to change buf, such an assertion could be
useful. IME, such code is rare, though.
next prev parent reply other threads:[~2024-07-18 17:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 15:23 Using static_assert in Emacs? Stefan Kangas
2024-07-18 15:42 ` Eli Zaretskii
2024-07-18 16:39 ` Stefan Kangas
2024-07-18 16:51 ` Collin Funk
2024-07-18 17:35 ` Eli Zaretskii [this message]
2024-07-19 0:48 ` Po Lu
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=865xt2fvrj.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=stefankangas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).