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 / Managed C++ / April 2006

Tip: Looking for answers? Try searching our database.

How to Force compiler to give error notice in "if" clause?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MilanB - 29 Apr 2006 16:40 GMT
Hi,

Is there a way to force Visual C++ compiler (VS 2003) to give an error or
notice in case of IF statment have "=" instead of "=="

for example
if(locationID = 10351)  is passing,   but I want an error fired

Thanks
Milan
Marcus Heege - 29 Apr 2006 16:59 GMT
warning C4706 (assignment within conditional expression) can report the
problem you describe.

Since it is a level 4 warning, you can see this warning if you compile with
/W4.
To see this elevate this warning to a level 1 warning, you can use /w14703.
To treat this warning as en error you can use /we4703

Marcus

> Hi,
>
[quoted text clipped - 6 lines]
> Thanks
> Milan
Bruno van Dooren - 29 Apr 2006 17:25 GMT
> Since it is a level 4 warning, you can see this warning if you compile
> with /W4.
> To see this elevate this warning to a level 1 warning, you can use
> /w14703.
> To treat this warning as en error you can use /we4703

Additionally, if you go to your project properties, then to configuration
properties -> C++ -> general
you can set the global warning level, and the global 'treat warnings as
errors' flag.

I have recently taken to compile all new projects with /W4 and all warnings
treated as error.
This way I can avoid typo bugs like the one you mentioned.

Signature

Kind regards,
   Bruno van Dooren
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"

- 29 Apr 2006 22:39 GMT
MB- [Sat, 29 Apr 2006 08:40:02 -0700]:
>if(locationID = 10351)  is passing,   but I want an error fired

Use (or rather, don't)

if (10351 = locationID)

and you won't have to worry about it.  Try
it, you'll like it.

Rate this thread:







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.