Skip to main content



      Home
Home » Newcomers » Newcomers » turn off unnecessary warning
turn off unnecessary warning [message #262409] Fri, 01 August 2008 12:43 Go to next message
Eclipse UserFriend
Originally posted by: samuelandjw.gmail.com

Hi! I'm a newcomer.

I just tried to compile a project without modifying the default
preference, but the compiler g++ warned me about the comparison between
signed and unsigned. This warning is quite annoying because I have a lot
of loops. I have searched through a lot of options and preferences in
Eclipse, but I have no idea how to turn it off.

thx
Re: turn off unnecessary warning [message #262414 is a reply to message #262409] Fri, 01 August 2008 15:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

This question might get more attention on the CDT newsgroup
(eclipse.tools.cdt), which I've copied to this response.

Sam wrote:
> Hi! I'm a newcomer.
>
> I just tried to compile a project without modifying the default
> preference, but the compiler g++ warned me about the comparison between
> signed and unsigned. This warning is quite annoying because I have a lot
> of loops. I have searched through a lot of options and preferences in
> Eclipse, but I have no idea how to turn it off.
Re: turn off unnecessary warning [message #262417 is a reply to message #262414] Fri, 01 August 2008 15:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jfisher.overstock.com

This is a g++ warning, nothing related to eclipse
essentially, using "int" is not preferred, but size_type or size_t (go
figure)
You can turn of this warning from g++ (google around for the -WXXX)
I'm not sure if you can filter it using eclipse error parsers

Eric Rizzo wrote:
> This question might get more attention on the CDT newsgroup
> (eclipse.tools.cdt), which I've copied to this response.
>
> Sam wrote:
>> Hi! I'm a newcomer.
>>
>> I just tried to compile a project without modifying the default
>> preference, but the compiler g++ warned me about the comparison
>> between signed and unsigned. This warning is quite annoying because I
>> have a lot of loops. I have searched through a lot of options and
>> preferences in Eclipse, but I have no idea how to turn it off.
Re: turn off unnecessary warning [message #262515 is a reply to message #262417] Tue, 05 August 2008 04:15 Go to previous message
Eclipse UserFriend
Originally posted by: root.local.host

>> Sam wrote:
>>> Hi! I'm a newcomer.
>>>
>>> I just tried to compile a project without modifying the default
>>> preference, but the compiler g++ warned me about the comparison
>>> between signed and unsigned. This warning is quite annoying because I
>>> have a lot of loops. I have searched through a lot of options and
>>> preferences in Eclipse, but I have no idea how to turn it off.

Joe Fisher <jfisher@overstock.com> wrote in news:g6vpbu$8mn$1
@build.eclipse.org:
> This is a g++ warning, nothing related to eclipse
> essentially, using "int" is not preferred, but size_type or size_t (go
> figure)
> You can turn of this warning from g++ (google around for the -WXXX)
> I'm not sure if you can filter it using eclipse error parsers

You can set up filters in the problem view.
Or, you can use -Wno-sign compare to shut up the warnings.


Sam, perhaps you should review those warnings. Comparison of signed and
unsigned quantities is suspect, because the rules are different. In an
operation between a signed and an unsigned int (of the same size),
unsigned "wins" (the signed quantity is automatically converted to
unsigned) and the operation is performed as unsigned. This can lead to
surptising results (the code below prints "Whoops!") and surprise in
software is bad.

#include <stdio.h>
int main()
{
unsigned int u = 2;
int i = -3;
if ( i > u )
puts( "Whoops!" );
else
puts( "ok" );
return 0;
}

If your loops have an upper limit which is size_t (e.g. from strlen() or
some_STL_container.size()) then the loop variable should be size_t also.

Perhaps we are safe 99.99% of the time, but I'm working on a 600000-line
project where this would mean 60 bugs hidden in the code.

I'm sticking to -Wall -pedantic -Wextra -Werror :)


--
Life is complex, with real and imaginary parts.
Previous Topic:annotation processor not working.
Next Topic:Axis2 Client
Goto Forum:
  


Current Time: Fri May 16 02:57:09 EDT 2025

Powered by FUDForum. Page generated in 0.12677 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top