gcc:how to avoid some warnings?

gcc:how to avoid some warnings?

Post by gdm » Fri, 30 Nov 2001 18:52:45



I have sco5.0.5. and I use cc to compile. I suppose that my problem is the
same in linux with gcc. So when I run cc, some warning are printed on the
screen. I know the cause of these warnings and I know that my code is OK. So
these warnings do not interest me. So I want to avoid to see them on the
screen when I compile with cc. But I do not want to stop any printing of
warnings. I would like to write in my code in C, something like
#no_print_warnings
signal(..........);/* my code in C */
#print_warnings_again

where could I find the syntax to do what I would like to do? When I do "man
cc", I do not find any help for me.

gdm

 
 
 

gcc:how to avoid some warnings?

Post by Eric P. McC » Sat, 01 Dec 2001 02:42:20



> I have sco5.0.5. and I use cc to compile. I suppose that my problem is the
> same in linux with gcc.

Why do you suppose that?

Post to a relevant newsgroup.

--

"I woke up this morning and realized what the game needed: pirates,
pimps, and gay furries."  - Rich "Lowtax" Kyanka

 
 
 

gcc:how to avoid some warnings?

Post by Donovan Rebbech » Sat, 01 Dec 2001 13:08:51




>> I have sco5.0.5. and I use cc to compile. I suppose that my problem is the
>> same in linux with gcc.

> Why do you suppose that?

> Post to a relevant newsgroup.

I'm writing code on Linux, and I'd like to see an answer to his question.
I haven't been able to find one in the gcc documentation.

In my case, the problem is that I'm not interested in seeing warnings
generated by the headers I'm including. I crank warnings up to monitor
the quality of my code, not the system libraries.

--
Donovan

 
 
 

gcc:how to avoid some warnings?

Post by Grant Edwar » Sat, 01 Dec 2001 14:23:01





>>> I have sco5.0.5. and I use cc to compile. I suppose that my problem is the
>>> same in linux with gcc.

>> Why do you suppose that?

>> Post to a relevant newsgroup.

>I'm writing code on Linux, and I'd like to see an answer to his question.
>I haven't been able to find one in the gcc documentation.

>In my case, the problem is that I'm not interested in seeing warnings
>generated by the headers I'm including. I crank warnings up to monitor
>the quality of my code, not the system libraries.

The best solution would be to fix the headers and submit a patch to the
maintainer.

--
Grant Edwards                   grante             Yow!  I was born in a
                                  at               Hostess Cupcake factory
                               visi.com            before the *
                                                   revolution!

 
 
 

gcc:how to avoid some warnings?

Post by Floyd Davidso » Sat, 01 Dec 2001 18:56:09





>>> I have sco5.0.5. and I use cc to compile. I suppose that my problem is the
>>> same in linux with gcc.

>> Why do you suppose that?

>> Post to a relevant newsgroup.

>I'm writing code on Linux, and I'd like to see an answer to his question.
>I haven't been able to find one in the gcc documentation.

>In my case, the problem is that I'm not interested in seeing warnings
>generated by the headers I'm including. I crank warnings up to monitor
>the quality of my code, not the system libraries.

I'd like to see some examples.  I tend to use several extra -W
options and rarely have ever had a problem with system headers.

With that said...  there are times when it is necessary to _not_
use ansi options, and possibly define macro's to invoke the
appropriate environment.  See /usr/include/features.h for a list
and at least a minimal indication of which macros to define for
which environment.

--
Floyd L. Davidson         <http://www.ptialaska.net/~floyd>

 
 
 

gcc:how to avoid some warnings?

Post by Donovan Rebbech » Sun, 02 Dec 2001 00:35:51




> I'd like to see some examples.  I tend to use several extra -W
> options and rarely have ever had a problem with system headers.

<sstream> spits out warnings. I suppose that one could "solve" the
problem by fixing sstream, but that doesn't help if I'm compiling on
systems I don't have root on.

--
Donovan

 
 
 

gcc:how to avoid some warnings?

Post by Thomas Dicke » Sun, 02 Dec 2001 02:49:46



> The best solution would be to fix the headers and submit a patch to the
> maintainer.

I don't believe the maintainers use compiler warnings (look at any release
of glibc).

--

http://dickey.his.com
ftp://dickey.his.com

 
 
 

gcc:how to avoid some warnings?

Post by Floyd Davidso » Sun, 02 Dec 2001 08:43:52





>> I'd like to see some examples.  I tend to use several extra -W
>> options and rarely have ever had a problem with system headers.

><sstream> spits out warnings. I suppose that one could "solve" the
>problem by fixing sstream, but that doesn't help if I'm compiling on
>systems I don't have root on.

I would expect that if you use it with gcc it would!  Can you
give me an example of the command line you are using and a very
short program that demonstrates what you mean.

--
Floyd L. Davidson         <http://www.ptialaska.net/~floyd>

 
 
 

gcc:how to avoid some warnings?

Post by Anthony W. Youngma » Mon, 31 Dec 2001 04:47:57







>>>> I have sco5.0.5. and I use cc to compile. I suppose that my problem is the
>>>> same in linux with gcc.

>>> Why do you suppose that?

>>> Post to a relevant newsgroup.

>>I'm writing code on Linux, and I'd like to see an answer to his question.
>>I haven't been able to find one in the gcc documentation.

>>In my case, the problem is that I'm not interested in seeing warnings
>>generated by the headers I'm including. I crank warnings up to monitor
>>the quality of my code, not the system libraries.

>The best solution would be to fix the headers and submit a patch to the
>maintainer.

Okay, this was Microsoft C ... but I've used a load of code where the
compiler kept on spewing warnings that I couldn't suppress.

I was passing call-through functions so my args list was defined by the
library calling my routines. However, most of the time I didn't need the
arguments, so the compiler kept on spewing either "argument not used" or
"this statement doesn't do anything" warnings.

The ability to suppress certain warnings would be welcomed...

Cheers,
Wol.
--
Anthony W. Youngman - wol at thewolery dot demon dot co dot uk
Witches are curious by definition and inquisitive by nature. She moved in. "Let
me through. I'm a nosey person.", she said, employing both elbows.
Maskerade : (c) 1995 Terry Pratchett

 
 
 

gcc:how to avoid some warnings?

Post by yugam » Tue, 01 Jan 2002 12:31:36


i am a firm believer that code should compile w/ out warning

> I was passing call-through functions so my args list was defined by the
> library calling my routines. However, most of the time I didn't need the
> arguments, so the compiler kept on spewing either "argument not used" or
> "this statement doesn't do anything" warnings.

 
 
 

gcc:how to avoid some warnings?

Post by Donovan Rebbech » Wed, 02 Jan 2002 00:54:31




> I was passing call-through functions so my args list was defined by the
> library calling my routines. However, most of the time I didn't need the
> arguments, so the compiler kept on spewing either "argument not used" or
> "this statement doesn't do anything" warnings.

In gcc, you can fix this by not naming unused parameters.

eg

/* second and third parameters unused, no warnings*/
int foo(int a, int, int )
{
        return 2*a;    

Quote:}

--
Donovan
 
 
 

gcc:how to avoid some warnings?

Post by Loren Lan » Wed, 02 Jan 2002 03:29:42



> i am a firm believer that code should compile w/ out warning

I agree, I even add the -Werror option along with -Wall to gcc
to make sure no warnings get by me.  I've had times before when
a warning (one that isn't produced without -Wall) told me ahead
of time that my program was likely to segment fault if I ran it,
but no errors so my code went ahead and tried to compile everything
instead of quiting immediately.


> > I was passing call-through functions so my args list was defined by the
> > library calling my routines. However, most of the time I didn't need the
> > arguments, so the compiler kept on spewing either "argument not used" or
> > "this statement doesn't do anything" warnings.

--
I sense much NT in you.
NT leads to Bluescreen.
Bluescreen leads to downtime.
Downtime leads to suffering.
NT is the path to the darkside.
Powerful Unix is.
 
 
 

gcc:how to avoid some warnings?

Post by Anthony W. Youngma » Thu, 03 Jan 2002 08:29:25



writes

Quote:>i am a firm believer that code should compile w/ out warning

So am I. Which is why I was responsible for it becoming policy at my
company that

a) the warning level should be set at max
b) all warnings should be dealt with

However, what do you do when the cause lies in a 3rd-party library and
(1) you can't find a way to suppress the warning, and
(2) you know that the warning is harmless.

Cheers,
Wol.


>> I was passing call-through functions so my args list was defined by the
>> library calling my routines. However, most of the time I didn't need the
>> arguments, so the compiler kept on spewing either "argument not used" or
>> "this statement doesn't do anything" warnings.

--
Anthony W. Youngman - wol at thewolery dot demon dot co dot uk
Witches are curious by definition and inquisitive by nature. She moved in. "Let
me through. I'm a nosey person.", she said, employing both elbows.
Maskerade : (c) 1995 Terry Pratchett
 
 
 

gcc:how to avoid some warnings?

Post by Anthony W. Youngma » Thu, 03 Jan 2002 08:32:23






>> I was passing call-through functions so my args list was defined by the
>> library calling my routines. However, most of the time I didn't need the
>> arguments, so the compiler kept on spewing either "argument not used" or
>> "this statement doesn't do anything" warnings.

>In gcc, you can fix this by not naming unused parameters.

>eg

>/* second and third parameters unused, no warnings*/
>int foo(int a, int, int )
>{
>       return 2*a;    
>}

CHEERS! Not much use to me any more, and maybe not much use then - it
was MS C6, after all - but at least I know now if I hit the same problem
in linux :-)

Cheers,
Wol
--
Anthony W. Youngman - wol at thewolery dot demon dot co dot uk
Witches are curious by definition and inquisitive by nature. She moved in. "Let
me through. I'm a nosey person.", she said, employing both elbows.
Maskerade : (c) 1995 Terry Pratchett

 
 
 

gcc:how to avoid some warnings?

Post by Kaz Kylhe » Mon, 07 Jan 2002 07:25:02



>i am a firm believer that code should compile w/ out warning

That is silly, because C and C++ compiler implementors are free
to add whatever warnings they like, including purely stylistic
warnings that express one developer's religious beliefs.

A conforming ANSI C compiler can warn whenever you place a curly
brace differently from what the compiler writer thinks is elegant.
Are you going to fix all instances of that? What if it contradicts
your local coding standard?

Catering to every single warning that a compiler implementor comes up
with is as irrational as ignoring all of them.

You have to investigate the cause of every warning. Then fix what is
reasonable.

 
 
 

1. avoid a warning for each module on s390x

s390x has a reference to _GLOBAL_OFFSET_TABLE_ in each module
that is resolved by the module loader. This patch prevents
modpost from emitting a warning about that symbol.

--- linux-2.5.63/scripts/modpost.c      Tue Feb 18 18:41:54 2003

                /* undefined symbol */
                if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL)
                        break;
+               /* ignore global offset table */
+               if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
+                       break;

                s = alloc_symbol(symname);
                /* add to list */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. display export

3. SUMMARY: avoiding ld.so warning

4. Problem setting password - 0.99pl14

5. How to avoid netscape warning for shell scripts?

6. Zip Zoom & SCSI Zip Drive

7. Netscape, how to avoid warnings?

8. seg fault with modules...

9. avoid warning of redirection to non-secure url from secure url

10. Warning Avoid I-Connect

11. PATCH - avoid 'defined but not used' warning in xor.h on i386

12. avoiding "ld.so warning ..."

13. AVOID* Computers Ur Way * AVOID