Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable narrowing conversion warnings?

Tags:

I use -Wall and updating to new gcc I have got a lot of warning: narrowing conversion. I want to disable them, but leave all other warnings untouched (ideally).

I can find nothing about narrowing in http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

How to disable narrowing conversion warnings? Is it possible at all?

P.S.

  1. I need to Disable warnings, not fix them in the source code.

  2. Blind -Wno-conversion doesn't help.

like image 707
klm123 Avatar asked Nov 30 '13 16:11

klm123


People also ask

How do you fix narrowing conversion error?

If you make a narrowing conversion intentionally, make your intentions explicit by using a static cast. Otherwise, this error message almost always indicates you have a bug in your code. You can fix it by making sure the objects you initialize have types that are large enough to handle the inputs.

What is a narrowing conversion?

A narrowing conversion changes a value to a data type that might not be able to hold some of the possible values. For example, a fractional value is rounded when it is converted to an integral type, and a numeric type being converted to Boolean is reduced to either True or False .

What is Wextra C++?

-Wextra. This enables some extra warning flags that are not enabled by -Wall . (This option used to be called -W . The older name is still supported, but the newer name is more descriptive.)


1 Answers

As gx_ said, adding -Wno-narrowing to your command line should ignore those errors. Encountered this myself when upgrading to C++0x.

like image 129
Stryck Avatar answered Sep 26 '22 21:09

Stryck