Reputation: 41
Getting a warning message as below which I am trying to get rid off
warning: initialization discards `const' from pointer target type
The code needs to stay as it is so in VS used Suppress Specific Warning but I was wondering if there is some way to do the same in gcc as well.
Using quite an older version of GCC compiler 3.4 all the other posts I have come across talk about higher versions. Some helpful posts-
How to supress specific warnings in g++
http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html
https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Warning-Options.html
Tried using-
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
//< code that generates warning >
#pragma GCC diagnostic pop
But then the warnings increase-
: warning: ignoring pragma: push
: warning: ignoring pragma: "-Wignored-qualifiers
: warning: initialization discards `const' from pointer target type
: warning: initialization discards `const' from pointer target type
: warning: ignoring pragma: pop
Upvotes: 3
Views: 845
Reputation: 16540
look here:
<gcc.gnu.org/onlinedocs/gcc/Option-Summary.html>;
for the list of the gcc options and look at:
<gcc.gnu.org/onlinedocs/gcc/…;
for more detailed descriptions.
This link:
<gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>
has this to say:
"Each of these specific warning options also has a negative form beginning ' -Wno- ' to turn off warnings;
for example, -Wno-implicit ."
Upvotes: 2