Reputation: 3
i have a specific warning that i would like to delete/ hide and then enable it just after. Do you have any idea how can i do that without deleting all the other warnings?
this is the warning i am getting
warning: enumeration value 'EtatCCSortie' not handled in switch [-Wswitch]
and i dont need to actually use that state in the switch (it's a state machine). I have a way to noy get this warning anymore which is by adding the state to the switch like this:
while (etatsImprimanteCasImpressionPeriodique != EtatIPSortie)
{
switch (etatsImprimanteCasChangementCartouche)
{
....
case EtatCCSortie:
break;
But i don't have to add it because it will never execute (while !=). that's why i am looking for a way to unable this specific warning and then enable it just after this switch.
Ps:i am aware of the importance of warnings and i only need a way to delete it.
Upvotes: 0
Views: 57
Reputation: 362
Using:
#pragma GCC diagnostic ignored "-W<replace_this_with_the_warning>"
Upvotes: 0
Reputation: 140970
Use diagnostic pragmas:
enum somenum {
EtatIPSortie,
EtatCCSortie,
};
int etatsImprimanteCasImpressionPeriodique;
enum somenum etatsImprimanteCasChangementCartouche;
void func() {
while (etatsImprimanteCasImpressionPeriodique != EtatIPSortie)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch"
switch (etatsImprimanteCasChangementCartouche)
{
case EtatCCSortie:
break;
}
#pragma GCC diagnostic pop
}
}
Upvotes: 1