Thread: How do I display all warning messages using Visual Studio 2005?

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    60

    How do I display all warning messages using Visual Studio 2005?

    Hey,
    I'm trying to show all the warning messages of my c++ program, similar to a -Wall command for linux. How can I do that?

    Right now I am using the command:
    >: cl /EHsc myProgram.cpp

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Go to project settings and set the warning level to /W4.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    60
    Nice, thank you.

    Im writting c++ code and its complaining about me using strcpy and strcmp.
    Should I not use those? Is it risky?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    If used incorrectly, yes. You can disable those warnings by defining the macro _CRT_SECURE_NO_WARNINGS in the project settings.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Why ARE you using strcpy etc in a C++ program?

    C++ has a perfectly usable std::string class.

    Even when you NEED a char array, say to open a filename, you use the c_str() method of your string.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    Quote Originally Posted by gp364481 View Post
    Hey,
    I'm trying to show all the warning messages of my c++ program, similar to a -Wall command for linux. How can I do that?
    Visual Studio has Wall too, though I wouldn't use it if you're including windows.h.
    cl /EHsc /Wall myProgram.cpp

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Interesting. I suppose this is new to VS10, since I haven't seen it in previous versions.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I've been able to use the -Wall option in VC++ in 2008, and I think 2005 also. It's probably been around a while, but there's no GUI option for it, so most people don't know it exists. It's also pretty much useless because it complains a LOT about Microsoft's own libraries...
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    There is a gui option in 2010, though. It pretty much shows all warnings, including merely informative ones. So it's not really complaining per se, but informing you more like it.
    W4 is probably the best trade-off. Or you could always use All and disable some warnings. It's easy to do globally in 2010.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem buidling in Visual Studio 2005 (new to C++)
    By ashley in forum C++ Programming
    Replies: 3
    Last Post: 12-17-2007, 03:14 AM
  2. Templates and Macros plus more...
    By Monkeymagic in forum C++ Programming
    Replies: 8
    Last Post: 01-20-2007, 05:53 PM
  3. using classes
    By krazykrisi in forum C++ Programming
    Replies: 9
    Last Post: 11-22-2006, 10:41 AM
  4. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM