public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Question on FIELD_PREP() for static array
@ 2018-10-10 17:16 John Garry
  2018-10-10 17:33 ` Joe Perches
  0 siblings, 1 reply; 9+ messages in thread
From: John Garry @ 2018-10-10 17:16 UTC (permalink / raw)
  To: Andrew Morton, Andy Shevchenko, Kalle Valo, johannes,
	jakub.kicinski, yamada.masahiro, Arnd Bergmann, viro,
	linux-kernel@vger.kernel.org

(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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-10-11 19:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-10 17:16 Question on FIELD_PREP() for static array John Garry
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox