DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>
Cc: <dev@dpdk.org>
Subject: RE: Function to fail at build time?
Date: Thu, 26 Jun 2025 17:23:40 +0200	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9FD46@smartserver.smartshare.dk> (raw)
In-Reply-To: <20250626073131.1b4e3449@hermes.local>

> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Thursday, 26 June 2025 16.32
> 
> On Thu, 26 Jun 2025 01:55:02 +0200
> Morten Brørup <mb@smartsharesystems.com> wrote:
> 
> > I was wondering if this was somehow possible:
> >
> > #define RTE_VERIFY(exp) do { \
> > +	if (__rte_constant(exp)) \
> > +		FAIL_AT_BUILD_TIME(); \
> > 	if (unlikely(!(exp))) \
> > 		rte_panic("line %d\tassert \"%s\" failed\n", __LINE__,
> #exp); \
> > } while (0)
> >
> > I tried static_assert(), but it cannot be used in this way.
> 
> 
> What happens?

The compiler says:
error: expected expression before '_Static_assert'

It seems static_assert is a declaration, so you cannot treat it as a function, using e.g.:
if (1) static_assert(1, "OK");



      reply	other threads:[~2025-06-26 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 23:55 Morten Brørup
2025-06-26 14:31 ` Stephen Hemminger
2025-06-26 15:23   ` Morten Brørup [this message]

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=98CBD80474FA8B44BF855DF32C47DC35E9FD46@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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.
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 NNTP newsgroup(s).