compiler error : get_if<> with a variant enum ?
Francine Sauvage
francine.sauvage at atos.net
Fri Oct 21 03:32:40 AEDT 2022
Hi Patrick
I was happy, I successfully added ModuleTypes in the variant lists:
It compiles.
But, I get a runtime error as all my objects are different:
what(): xyz.openbmc_project.sdbusplus.Error.InvalidEnumString: An enumeration mapping was attempted for which no valid enumeration value exists.
Is there a way to add enum types to the variant of a ManagedObjects that potentially are NOT in the object interfaces/Properties ?
Or is there a way to filter the objects in ManagedObjects dbus calls ?
Kind Regards,
Francine SAUVAGE
Team Leader - R&D, BDS
Atos France
Mobile: +33 6 21 43 11 21
R&D, BDS
Avenue Jean Jaurès - France
atos.net
TT: [Wednesday or Thurday(2nd week of month) ] - Friday]
OoO : October 31
-----Message d'origine-----
De : Francine Sauvage
Envoyé : jeudi 20 octobre 2022 10:36
À : Patrick Williams <patrick at stwcx.xyz>
Cc : openbmc at lists.ozlabs.org
Objet : RE: compiler error : get_if<> with a variant enum ?
Hi Patrick,
Many thanks to answer me.
I prepared a mail for 2 days, but ... I am still testing your suggestions.
I included the generated server.hpp but not the generated server.cpp as a library.
It could explain my problem.
I am not able to add my enum (ModulesTypes) in the variant list.
It should disturb the generated mechanism.
So I added the generated library (similar/specific phosphor-dbus-interfaces)
I'll let you know,
Regards,
Francine SAUVAGE
Team Leader - R&D, BDS
Atos France
Mobile: +33 6 21 43 11 21
R&D, BDS
Avenue Jean Jaurès - France
atos.net
TT: [Wednesday or Thurday(2nd week of month) ] - Friday] OoO : October 31
-----Message d'origine-----
De : Patrick Williams <patrick at stwcx.xyz>
Envoyé : mardi 18 octobre 2022 01:37
À : Francine Sauvage <francine.sauvage at atos.net>
Cc : openbmc at lists.ozlabs.org
Objet : Re: compiler error : get_if<> with a variant enum ?
On Mon, Oct 17, 2022 at 08:13:20AM +0000, Francine Sauvage wrote:
>
> const auto* flexible_module_type =
> std::get_if<sdbusplus::xyz::openbmc_project::Inventory::Item::server::
> FlexibleModule::ModuleTypes>(&flexible_prop_map_iterator->second);
>
> ** I tried to replace auto with
> sdbusplus::xyz::openbmc_project::Inventory::Item::server::FlexibleModu
> le::ModuleTypes>
> No success.
>
> Error is :
>
> bmcweb/1.0+git1.0-r0/recipe-sysroot/usr/include/c++/10.2.0/variant:115
> 0:42: error: static assertion failed: T must occur exactly once in
> alternatives static_assert(__detail::__variant::__exactly_once<_Tp,
> _Types...>,
What type is `flexible_prop_map_iterator->second`? It seems likely it is a variant that doesn't have the enumeration type in the list of contained types. "T must occur exactly one in alternatives" seems to be saying that `ModuleTypes` wasn't part of the underlying variant types.
--
Patrick Williams
More information about the openbmc
mailing list