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

This is a discussion on How do I display all warning messages using Visual Studio 2005? within the C++ Programming forums, part of the General Programming Boards category; Hey, I'm trying to show all the warning messages of my c++ program, similar to a -Wall command for linux. ...

  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
    21,436
    Go to project settings and set the warning level to /W4.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    21,436
    If used incorrectly, yes. You can disable those warnings by defining the macro _CRT_SECURE_NO_WARNINGS in the project settings.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    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, 02:14 AM
  2. Templates and Macros plus more...
    By Monkeymagic in forum C++ Programming
    Replies: 8
    Last Post: 01-20-2007, 04:53 PM
  3. using classes
    By krazykrisi in forum C++ Programming
    Replies: 9
    Last Post: 11-22-2006, 09: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, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21