[solved]mingw pragma warning disable

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

[solved]mingw pragma warning disable

Post by REDDemon »

Is that really true that mingw doesn't allows to disable specific pragma warnings? I think that disabling warning is really usefull when needed. Because they usually hide warnings wich needs more attention and reduce compile time if they are too many.

EDIT: thanks you docWild. It worked! :)
Last edited by REDDemon on Sun Dec 11, 2011 1:40 pm, edited 1 time in total.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: mingw pragma warning disable

Post by serengeor »

It is possible to turn off every warning, not sure about turning off specific ones. But if you're concerned about compile time, why not turn off all of the warnings and when you need to check for warnings turn them back on?
Working on game: Marrbles (Currently stopped).
CuteAlien
Admin
Posts: 9680
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: mingw pragma warning disable

Post by CuteAlien »

You can disable warnings globally with compiler options. Check the gcc manual for that. Disabling them only per file wasn't possible in the past, it might be possible when gcc 4.6 hit's MinGW: http://stackoverflow.com/questions/9650 ... ation-unit
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: mingw pragma warning disable

Post by randomMesh »

Warnings are there for a reason. I'd fix my code rather than disabling the warnings...
"Whoops..."
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: mingw pragma warning disable

Post by hybrid »

Problem is if your library provider won't think the same as you, though. Then it becomes handy to disable warnings when including external headers, and re-enable them later on. But of course this is still a workaround, just one which is mostly inevitable otherwise
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: mingw pragma warning disable

Post by hendu »

For broken external includes, use -isystem instead of -I and they don't get scanned for warnings.

/me always runs with -Wall -Wextra.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: mingw pragma warning disable

Post by hybrid »

Oh, didn't knew that.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: mingw pragma warning disable

Post by REDDemon »

I usually enable always Wall Wextra. And I disable all warnings in the release version. But the point is that Some warnings are thrown because of certain choices (for example reinterpret casting a pointer to u32 to a pointer to f32 etc..) I wanted to disable warning on a per-file basis in order to hide wanted warnings and easily catch unwanted warnings and fixe the code for them. In visual studio this is possible. Don't know if and how with mingw. :(
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
docWild
Posts: 38
Joined: Wed Nov 30, 2011 4:29 pm

Re: mingw pragma warning disable

Post by docWild »

REDDemon wrote:I usually enable always Wall Wextra. And I disable all warnings in the release version. But the point is that Some warnings are thrown because of certain choices (for example reinterpret casting a pointer to u32 to a pointer to f32 etc..) I wanted to disable warning on a per-file basis in order to hide wanted warnings and easily catch unwanted warnings and fixe the code for them. In visual studio this is possible. Don't know if and how with mingw. :(
Something like -Wconversion

From here http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: mingw pragma warning disable

Post by hendu »

Are you talking about the hack in irr api where it's needed to pass ints as floats to set GLSL texture units?
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: mingw pragma warning disable

Post by randomMesh »

There still is no point in hiding the warnings. If you use an external library and it throws warning on compilation, write an email to the developers and ask them to fix them. If they won't, you still can have a paragraph in your readme.txt which states that the warnings are not from your code but from another library. So more people would email the lazy developers.

Don't hide the truth!

PS: -Werror -pedantic rocks ;)
"Whoops..."
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: mingw pragma warning disable

Post by REDDemon »

randomMesh wrote:There still is no point in hiding the warnings. If you use an external library and it throws warning on compilation, write an email to the developers and ask them to fix them. If they won't, you still can have a paragraph in your readme.txt which states that the warnings are not from your code but from another library. So more people would email the lazy developers.

Don't hide the truth!

PS: -Werror -pedantic rocks ;)
The point is that when you are writing a library you usually write code wich throws warnings. This is not hiding the truth. The truth is that if you have 50 warnings and 49 of them don't need attention but 1 of them is really imporant you will not notice that error. Disabling warnings where necessary is very usefull. When you have to deal with small libraries it doesn't matter if few warnings are throwed. But when you have dozens of code files and you start getting 300 warnings you want to turn them off (for example building glew usually throws how many warning as the number of wrapped gl functions. But that library is very good indeed this is just a example).

1) warnings are usefull to catch possible errors.
2) if there are too many warnings you will pay less attention on warning wich really need attention.

A good designed code have to shut down unwanted warnings. But disabling warnings separately for each file is possible only in visual studio as far as I know. Spending time on shutting down warnings is not lazy development.Every warning needs attention. After attention has been done on that warning and you think that it is ok, after some test you can disable it and go to the next warning. Using compiler options is not very good since the code becomes IDE/compiler dependent. (how can you put a -Wextra in a .h file?)
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
docWild
Posts: 38
Joined: Wed Nov 30, 2011 4:29 pm

Re: mingw pragma warning disable

Post by docWild »

REDDemon wrote:But disabling warnings separately for each file is possible only in visual studio as far as I know.
You can use pragma.

Code: Select all

#pragma GCC diagnostic ignored "-Wwrite-strings"
I believe you can use "#pragma GCC diagnostic pop" and "#pragma GCC diagnostic push" to do it on a per-line basis.

I agree with you in that warnings aren't a challenge to developers to test their metal at eradicating them. They are there for information.
Post Reply