LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   suppress a particular warning (https://www.linuxquestions.org/questions/programming-9/suppress-a-particular-warning-821565/)

yousafsajjad 07-22-2010 04:21 PM

suppress a particular warning
 
In gcc, does anyone know how to suppress a particular warning. I want to suppress "warning: useless storage class specifier in empty declaration"

pfelecan 07-23-2010 03:22 AM

By correcting the corresponding code or using -Wold-style-declaration. I strongly recommend the first approach...

JohnGraham 07-23-2010 03:42 AM

Quote:

Originally Posted by pfelecan (Post 4042755)
By correcting the corresponding code or using -Wold-style-declaration. I strongly recommend the first approach...

I agree. If you're really not sure what's causing the warning, please post the code (i.e. a small sample that (i) generates the warning and (ii) any of us can cut & paste into an editor and instantly compile to see the warning) so we can take a look and tell you how to fix it.

yousafsajjad 07-23-2010 09:43 AM

I know why is it giving a warning and I can fix it but I am asked not to change it rather try ignoring it some how using some gcc command
Sample
Code:

typedef struct Student S;

typedef struct Student
{
char name[20];
S *next;
};

But I can still see the warning with -Wold-style-declaration.

JohnGraham 07-23-2010 10:31 AM

Quote:

Originally Posted by yousafsajjad (Post 4043104)
I know why is it giving a warning and I can fix it but I am asked not to change it rather try ignoring it some how using some gcc command

By who? Who on earth would ask you to do that? Are you making this up because you started off wanting to suppress the warning without changing the code and are now dead-set on achieving that?

Just take out the typedef, because you're not typedef-ing anything. You may as well try and declare it static and to have an int return type.

If an instructor/teacher has asked you to do this as an exercise in suppressing warnings or whatever, slap them from me. If it's a question in a book, tell me the title so I can find all the copies and burn them. It's a useless exercise and if anyone set it, they should feel ashamed of themselves.


P.S. Sorry for the rudeness (I'm British, and hence must apologise for everything) but seriously - it's such a waste of your time and effort it's just downright rude.

wje_lq 07-23-2010 08:18 PM

Quote:

Originally Posted by JohnGraham (Post 4043176)
If an instructor/teacher has asked you to do this as an exercise in suppressing warnings or whatever, slap them from me. If it's a question in a book, tell me the title so I can find all the copies and burn them. It's a useless exercise and if anyone set it, they should feel ashamed of themselves.

wje_lq likes this.

yousafsajjad 07-23-2010 11:20 PM

i totally understand your point .. and i agree to it but this is how it is .. thanks anyways

phorgan1 10-09-2011 02:00 AM

Sure, I wrote a white paper on suppressing warnings in GCC.
 
I originally wrote it for the boost wiki, but enhanced it a bit for my web site. http://dbp-consulting.com/tutorials/...CWarnings.html


All times are GMT -5. The time now is 04:40 AM.