nla_policy results in "sorry, unimplemented: non-trivial designated initializers not supported" during compile

Bushman, Jeff JBushman at ciena.com
Thu Jul 21 17:50:35 PDT 2016


C++ does not support this style of structure initialization, only C.
The C++ idiom is a constructor or initializer-list

-----Original Message-----
From: libnl [mailto:libnl-bounces at lists.infradead.org] On Behalf Of Avery Rozar
Sent: Thursday, July 21, 2016 4:30 PM
To: David Ahern
Cc: libnl at lists.infradead.org
Subject: Re: nla_policy results in "sorry, unimplemented: non-trivial designated initializers not supported" during compile

That's the one.. I suspected I may have to implement differently. I did run What I needed without the policy, just used NULL instead I just want to try and understand what I'm doing better.

On Thu, Jul 21, 2016 at 7:25 PM, David Ahern <dsa at cumulusnetworks.com> wrote:
> On 7/21/16 5:02 PM, Avery Rozar wrote:
>>
>> For example in info.c from "iw" they build an nla_policy 
>> freq_policy[] like this..
>>
>> static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
>>    [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
>>    [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
>>    [NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG },
>>    [__NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
>>    [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
>>    [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 }, };
>>
>> Is the ".type" in "{ .type = NLA_U32 }" defined by "uint16_t type"?
>> Also the compile error points to the end of this freq_policy array. 
>> Is it because I'm using a c file as an example and this would need to 
>> be coded differently in c++?
>
>
> you mean this error:
> $ g++ -I/usr/include/libnl3/ -c nl-ex.c
> nl-ex.c: In function ‘int main()’:
> nl-ex.c:14:2: sorry, unimplemented: non-trivial designated 
> initializers not supported
>   };
>   ^
> nl-ex.c:14:2: sorry, unimplemented: non-trivial designated 
> initializers not supported
> nl-ex.c:14:2: sorry, unimplemented: non-trivial designated 
> initializers not supported
> nl-ex.c:14:2: sorry, unimplemented: non-trivial designated 
> initializers not supported
> nl-ex.c:14:2: sorry, unimplemented: non-trivial designated 
> initializers not supported
>
> gcc is fine with it; g++ not.
>
> Perhaps the C++ version needs to be implemented differently:
>
> http://stackoverflow.com/questions/31215971/non-trivial-designated-ini
> tializers-not-supported

_______________________________________________
libnl mailing list
libnl at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/libnl


More information about the libnl mailing list