Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

"Comparison to integral constant is useless; the constant is outside the range of type 'int'"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Claire - 03 Sep 2007 10:52 GMT
"Comparison to integral constant is useless; the constant is outside the
range of type 'int'"
How can I fix this compiler warning, please, for the following pseudocode?

int m_nError;
m_nError = somedriverapi.DoSomething();
if (m_nError != 0x8010002F) foobar; << compiler warning here

thankyou
Claire
Vadym Stetsiak - 03 Sep 2007 11:04 GMT
Hello, Claire!

Warning is generated, because value 0x8010002F exceeds the valid range of
int type.
Due to sign information max value of int is 2^31

You can use uint instead of int. uint max value is 2^32. Or use cast to
uint.
if ((uint)m_nError != 0x8010002F) foobar;

--
With best regards, Vadym Stetsiak.
Blog: http://vadmyst.blogspot.com

You wrote  on Mon, 3 Sep 2007 10:52:42 +0100:

C> "Comparison to integral constant is useless; the constant is outside
C> the  range of type 'int'"
C> How can I fix this compiler warning, please, for the following
C> pseudocode?

C> int m_nError;
C> m_nError = somedriverapi.DoSomething();
C> if (m_nError != 0x8010002F) foobar; << compiler warning here

C> thankyou
C> Claire

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.