mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Kalle Valo <kvalo@codeaurora.org>, <johannes@sipsolutions.net>,
	<jakub.kicinski@netronome.com>, <yamada.masahiro@socionext.com>,
	Arnd Bergmann <arnd@arndb.de>, <viro@zeniv.linux.org.uk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Question on FIELD_PREP() for static array
Date: Wed, 10 Oct 2018 18:16:32 +0100	[thread overview]
Message-ID: <c8594a75-964b-01b0-382e-88bcb5b462f2@huawei.com> (raw)

(to: get_maintainers -f include/linux/bitfield.h)

Hi,

I would like to use FIELD_PREP() macro for assigning a static array, 
like this:
function()
{
	static u32 val[2] = {FIELD_PREP(GENMASK_ULL(10, 0), 5), 0};

}

However the compiler complains of non-const expression:
./include/linux/bitfield.h:88:2: error: initializer element is not constant
    ({        \

Specifically it doesn't like the __BF_FIELD_CHECK() in FIELD_PREP().

Any ideas on compiler trickery we could do with the FIELD_PREP() 
definition to avoid this issue (i.e. enforce the check but only use the 
constant value)?

Thanks in advance,
John


             reply	other threads:[~2018-10-10 17:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 17:16 John Garry [this message]
2018-10-10 17:33 ` Joe Perches
2018-10-10 18:13   ` Johannes Berg
2018-10-11 14:24     ` John Garry
2018-10-11 15:23       ` Johannes Berg
2018-10-11 16:16         ` John Garry
2018-10-11 17:26           ` John Garry
2018-10-11 19:13             ` Johannes Berg
2018-10-11 19:22               ` Johannes Berg

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=c8594a75-964b-01b0-382e-88bcb5b462f2@huawei.com \
    --to=john.garry@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=jakub.kicinski@netronome.com \
    --cc=johannes@sipsolutions.net \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yamada.masahiro@socionext.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®