public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Maciej Cencora <m.cencora@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree: Fix up tree_code_{length,type}
Date: Fri, 27 Jan 2023 21:44:21 +0100	[thread overview]
Message-ID: <CAPFqmUq6ToGT1m1LhOA1T9U+i2h+m7Eg_sJEr=GzCPXKwiFcNQ@mail.gmail.com> (raw)

Hi,

you can emulate C++17 inline variables in C++11 with either of the two ways:

1) via a template helper
template <typename = void>
struct Helper
{
    static constexpr unsigned value[4] = {1, 2, 3, 4};
};

template <typename T>
constexpr unsigned Helper<T>::value[4];

static constexpr auto& arr = Helper<>::value;

2) extern constexpr + weak attribute
[[gnu::weak]] extern constexpr unsigned arr[] = {1, 2, 3, 4};

Regards,
Maciej

             reply	other threads:[~2023-01-27 20:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27 20:44 Maciej Cencora [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-11-18 18:05 [PATCH] constexprify some tree variables apinski
2023-01-26 14:45 ` Patrick Palka
2023-01-26 15:59   ` [PATCH] tree: Fix up tree_code_{length,type} Jakub Jelinek
2023-01-26 18:03     ` Patrick Palka
2023-01-27 12:40       ` Patrick Palka
2023-01-27 13:14         ` Richard Biener
2023-01-27  7:42     ` Richard Biener
2023-01-27  8:57       ` Jakub Jelinek
2023-01-27  9:49         ` Richard Biener

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='CAPFqmUq6ToGT1m1LhOA1T9U+i2h+m7Eg_sJEr=GzCPXKwiFcNQ@mail.gmail.com' \
    --to=m.cencora@gmail.com \
    --cc=gcc-patches@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).