LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-22-2010, 05:21 PM   #1
yousafsajjad
Member
 
Registered: Jun 2010
Posts: 50

Rep: Reputation: 15
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"
 
Old 07-23-2010, 04:22 AM   #2
pfelecan
LQ Newbie
 
Registered: Jun 2010
Posts: 9

Rep: Reputation: 1
By correcting the corresponding code or using -Wold-style-declaration. I strongly recommend the first approach...
 
Old 07-23-2010, 04:42 AM   #3
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by pfelecan View Post
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.
 
Old 07-23-2010, 10:43 AM   #4
yousafsajjad
Member
 
Registered: Jun 2010
Posts: 50

Original Poster
Rep: Reputation: 15
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.
 
Old 07-23-2010, 11:31 AM   #5
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by yousafsajjad View Post
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.

Last edited by JohnGraham; 07-23-2010 at 11:32 AM.
 
Old 07-23-2010, 09:18 PM   #6
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 178Reputation: 178
Quote:
Originally Posted by JohnGraham View Post
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.
 
Old 07-24-2010, 12:20 AM   #7
yousafsajjad
Member
 
Registered: Jun 2010
Posts: 50

Original Poster
Rep: Reputation: 15
i totally understand your point .. and i agree to it but this is how it is .. thanks anyways
 
Old 10-09-2011, 03:00 AM   #8
phorgan1
LQ Newbie
 
Registered: May 2008
Posts: 9

Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Suppress a particular gcc compiler warning? lamar_air Programming 7 10-09-2011 03:04 AM
suppress known warning message powah Programming 4 11-17-2007 09:34 PM
How to suppress particular warning message? hottdogg Programming 3 03-02-2007 02:15 AM
suppress warning messages h/w Programming 2 10-07-2003 03:56 PM
how to suppress colors frankie_g Linux - Newbie 6 05-15-2002 11:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration