Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Treat warnings as errors ?

Treat warnings as errors ?

Scheduled Pinned Locked Moved The Lounge
question
42 Posts 26 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Emilio Garavaglia

    Nice, and what about HFONT CreateFont(int,int,int,int,int,int,int,int,int,int,int,int,int,LPCTSTR); at least names suggest something more about the possible usage (!)

    2 bugs found. > recompile ... 65534 bugs found. :doh:

    C Offline
    C Offline
    Cedric Moonen
    wrote on last edited by
    #23

    emilio_grv wrote:

    Nice, and what about HFONT CreateFont(int,int,int,int,int,int,int,int,int,int,int,int,int,LPCTSTR); at least names suggest something more about the possible usage (!)

    Some remarks: 1) the problem occurs when you define your own function with some parameters and do not use all of them inside your function. Suppose that you want to provide a global CreateFont function, then it doesn't make any sense at all to provide so many parameters but not use a single one inside the CreateFont function. It seems wrong to me, because the user can provide whatever parameters, the function will not use them. So why do you need to provide them ? 2) There are some cases where you can't avoid that: like for example you have a virtual function in a base class that you want to specialize in the child class but do not use all parameters in the function. In that case, your parameters are still named in the prototype declared in the base class. 3) Nothing prevents you to give a name to the parameter in the function prototype but no name in the function definition. But I agree, the other propositions also make sense (using the UNREFERECED_PARAMETER macro or commenting their names).

    Cédric Moonen Software developer
    Charting control [v1.4] OpenGL game tutorial in C++

    1 Reply Last reply
    0
    • M Mike Diack

      I can't speak for others, but I personally always do. I do know that sometimes (especially VC6's STL code), library headers etc produce warnings, but I always think it's worth wrapping #pragma's around such situations to disable the warnings. Having code compile clean with /W4 /WX is a very useful baseline, potential breakage is instantly spotted. I have to admit I take it further as well by using Gimpel's PC Lint and Microsoft's own C++ static analysis (/analyze) tools in VC 2005 and later. Mike

      A Offline
      A Offline
      Anna Jayne Metcalfe
      wrote on last edited by
      #24

      Hello Mike - fancy bumping into you here! :laugh:

      Anna :rose: Having a bad bug day? Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"

      1 Reply Last reply
      0
      • C Christian Flutcher

        Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?

        F Offline
        F Offline
        Franc Morales
        wrote on last edited by
        #25

        I always use "warning level 4" and I always deal with all warnings.. "treat warnings as errors" is not necessary. In fact, "treat warnings as errors" is a pain since it would stop builds when I want to postpone, for example, deleting an unused variable. I would say that using "warning level 4" is far more important than using "treat warnings as errors".

        1 Reply Last reply
        0
        • C Christian Flutcher

          Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?

          E Offline
          E Offline
          Ennis Ray Lynch Jr
          wrote on last edited by
          #26

          When I am working as a lone developer absolutely. However, when I am part of a large team there are just too many monkeys running around claiming to write code. While my individual code will compile without warnings I just don't have the time or patience to fix the logical fallacies of other developers.

          Need a C# Consultant? I'm available.
          Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

          1 Reply Last reply
          0
          • H hairy_hats

            No I don't, but then the only errors I get are VC6 STL warnings on the length of the names. Well, those are the only ones I get at level 3, at level 4 there are lots but it's a legacy project which is too big to sort out. :(

            J Offline
            J Offline
            John M Drescher
            wrote on last edited by
            #27

            Take a look at this: http://www.bdsoft.com/tools/stlfilt.html[^] I use that to nuke those darn (useless) length too long warnings.

            John

            1 Reply Last reply
            0
            • C Christian Flutcher

              Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?

              D Offline
              D Offline
              Dave Parker
              wrote on last edited by
              #28

              We have it turned on for all projects at work, plus the build on the build server fails if there are any warnings. The unreachable code warnings raised as errors can be a pain at times though when you're doing a few quick tests locally - end up either having to comment out large sections temporarily or changing the project settings temporarily so they aren't treated as errors. That warning is also triggered when conditional compilation is used (so pragmas have to be put in to temporarily disable them).

              1 Reply Last reply
              0
              • C Christian Flutcher

                Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?

                M Offline
                M Offline
                Marc Clifton
                wrote on last edited by
                #29

                ForumExpertOnLine wrote:

                Do you used to turn it on ?

                No, but when I see warnings, I treat them as errors and fix them. But then again, I also don't use the stupid window that categorizes warnings and errors and tasks and whatever. I find it totally useless, as it doesn't give them to me in the right order (in my experience, I could be wrong), as it often gives me errors in dependent assemblies when the real problem is in the dependency (I'm talking C# development here basically). I just set the "Show Output" window to true and set the verbosity to minimum. Marc

                Thyme In The Country Interacx My Blog

                C 1 Reply Last reply
                0
                • C Christian Flutcher

                  Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #30

                  Well thanks for reminding me to check mine. :-D I have that turned off and I use warning level 4. But here's the situation: for my primary library project I have the release build produce an XML documentation file, which results in (currently) 1390 warnings of type 1591: "Missing XML comment for publicly visible type or member '...'" Which sometimes (as I just did) I choose to suppress, but most of the time I don't. I think maybe I should suppress it most of the time. :~

                  C 1 Reply Last reply
                  0
                  • C Christian Flutcher

                    Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?

                    C Offline
                    C Offline
                    Chris Maunder
                    wrote on last edited by
                    #31

                    Always.

                    cheers, Chris Maunder

                    CodeProject.com : C++ MVP

                    C 1 Reply Last reply
                    0
                    • C Christian Flutcher

                      Do you used to turn it on ? I always plan to do so, but the number of warnings will force me to turn it off again. I would like to know is it worth turning that option "on" ?

                      J Offline
                      J Offline
                      Joe Woodbury
                      wrote on last edited by
                      #32

                      Always for release builds. For debug builds when the product is in, or close to, maintenance phase. I also put warnings at 4, though with very small number of exceptions. I worked on a project once that had over 8,000 warnings at level 3. (I was told that it was 20,000+ at one point.) Apparently, the previous developers would redirect the warnings into a file and do a diff on it and examine the diff. They would choose which warnings to ignore and which ones to fix and then create a new master warnings file. My boss and coworker eliminated all the warnings, cranked it up to level 4, and eliminated those. The crazy part is how often the warnings really were indicating serious problems. For the record, here is my standard list of ignored warnings.

                      #pragma warning(disable : 4710) // function not inlined
                      #pragma warning(disable : 4711) // function 'function' selected for inline expansion
                      #pragma warning(disable : 4200) // nonstandard extension used : zero-sized array in struct/union

                      Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

                      1 Reply Last reply
                      0
                      • M Marc Clifton

                        ForumExpertOnLine wrote:

                        Do you used to turn it on ?

                        No, but when I see warnings, I treat them as errors and fix them. But then again, I also don't use the stupid window that categorizes warnings and errors and tasks and whatever. I find it totally useless, as it doesn't give them to me in the right order (in my experience, I could be wrong), as it often gives me errors in dependent assemblies when the real problem is in the dependency (I'm talking C# development here basically). I just set the "Show Output" window to true and set the verbosity to minimum. Marc

                        Thyme In The Country Interacx My Blog

                        C Offline
                        C Offline
                        Christian Flutcher
                        wrote on last edited by
                        #33

                        Marc Clifton wrote:

                        set the verbosity to minimum.

                        That's sounds good. Can you tell me how to set the verbosity to minimum ? I didn't find any options.

                        M 1 Reply Last reply
                        0
                        • P PIEBALDconsult

                          Well thanks for reminding me to check mine. :-D I have that turned off and I use warning level 4. But here's the situation: for my primary library project I have the release build produce an XML documentation file, which results in (currently) 1390 warnings of type 1591: "Missing XML comment for publicly visible type or member '...'" Which sometimes (as I just did) I choose to suppress, but most of the time I don't. I think maybe I should suppress it most of the time. :~

                          C Offline
                          C Offline
                          Christian Flutcher
                          wrote on last edited by
                          #34

                          PIEBALDconsult wrote:

                          "Missing XML comment for publicly visible type or member '...'"

                          I had this on a "Settings" class. I use #pragma to hide it.

                          W 1 Reply Last reply
                          0
                          • C Chris Maunder

                            Always.

                            cheers, Chris Maunder

                            CodeProject.com : C++ MVP

                            C Offline
                            C Offline
                            Christian Flutcher
                            wrote on last edited by
                            #35

                            But sometimes it's annoying, mainly when XML comments are turned on.

                            C 1 Reply Last reply
                            0
                            • C Christian Flutcher

                              Marc Clifton wrote:

                              set the verbosity to minimum.

                              That's sounds good. Can you tell me how to set the verbosity to minimum ? I didn't find any options.

                              M Offline
                              M Offline
                              Marc Clifton
                              wrote on last edited by
                              #36

                              ForumExpertOnLine wrote:

                              That's sounds good. Can you tell me how to set the verbosity to minimum ? I didn't find any options.

                              Tools/Options, open "Projects and Solutions", then click on "Build and Run". On the right, there's "MSBuild project build output verbosity". Set it to "Quiet". Then it finally behaves like VS2005. :sigh: Marc

                              Thyme In The Country Interacx My Blog

                              C 1 Reply Last reply
                              0
                              • M Marc Clifton

                                ForumExpertOnLine wrote:

                                That's sounds good. Can you tell me how to set the verbosity to minimum ? I didn't find any options.

                                Tools/Options, open "Projects and Solutions", then click on "Build and Run". On the right, there's "MSBuild project build output verbosity". Set it to "Quiet". Then it finally behaves like VS2005. :sigh: Marc

                                Thyme In The Country Interacx My Blog

                                C Offline
                                C Offline
                                Christian Flutcher
                                wrote on last edited by
                                #37

                                Done ! Thanks for that. It looks much interesting than seeing the error window. It shows warnings too and can be fixed on spot. Great suggestion marc.

                                1 Reply Last reply
                                0
                                • C Christian Flutcher

                                  But sometimes it's annoying, mainly when XML comments are turned on.

                                  C Offline
                                  C Offline
                                  Chris Maunder
                                  wrote on last edited by
                                  #38

                                  This is one of the main reasons I insist it's turn on: Every method should be commented without exception.

                                  cheers, Chris Maunder

                                  CodeProject.com : C++ MVP

                                  1 Reply Last reply
                                  0
                                  • C Christian Flutcher

                                    PIEBALDconsult wrote:

                                    "Missing XML comment for publicly visible type or member '...'"

                                    I had this on a "Settings" class. I use #pragma to hide it.

                                    W Offline
                                    W Offline
                                    Ware Work
                                    wrote on last edited by
                                    #39

                                    I've used the #pragma on Crystal reports too. I have it turned on and level 4 and XML docs on.

                                    WarePhreak Programmers are tools to convert caffiene to code.

                                    1 Reply Last reply
                                    0
                                    • C Cedric Moonen

                                      ForumExpertOnLine wrote:

                                      Most of them are unused variable warnings

                                      Why don't you just remove those unused variables then ? If it is an argument of one of your function and you can't remove it (e.g. virtual function), do not name it:

                                      void MyFunction(int)
                                      {
                                      // Code here
                                      }

                                      Cédric Moonen Software developer
                                      Charting control [v1.4] OpenGL game tutorial in C++

                                      R Offline
                                      R Offline
                                      Rajesh R Subramanian
                                      wrote on last edited by
                                      #40

                                      Hey pal, I want your opinions here: http://www.codeproject.com/script/Forums/View.aspx?fid=2605&msg=2661564[^]

                                      Please leave us our small pleasures, they are small, but they are ours! - Mycroft Holmes ^ .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

                                      C 1 Reply Last reply
                                      0
                                      • R Rajesh R Subramanian

                                        Hey pal, I want your opinions here: http://www.codeproject.com/script/Forums/View.aspx?fid=2605&msg=2661564[^]

                                        Please leave us our small pleasures, they are small, but they are ours! - Mycroft Holmes ^ .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

                                        C Offline
                                        C Offline
                                        Cedric Moonen
                                        wrote on last edited by
                                        #41

                                        Honnestly, I know that such discussions by mail or on a forum lead to nothing. This is very difficult to talk about something 'serious' for several reasons: 1) A part of the communication is missing: the only thing you see is text on a screen. So, misunderstanding somebody happens very easily. When you talk to somebody, there is much more to the conversion than just the words. 2) It is easier to write something that you don't really think just because you are a bit angry or had a bad day. You just type something on your keyboard and that's it. It's totaly different if you actually had that person in front of you. Perhaps that was said just as a joke, who knows. But I agree it's a bit playing with fire. I think you should simply let it go and stop it before it escalates too far. You know who you are and I can tell you that you are not a shame to your country, it is even the opposite :)

                                        Cédric Moonen Software developer
                                        Charting control [v1.4] OpenGL game tutorial in C++

                                        R 1 Reply Last reply
                                        0
                                        • C Cedric Moonen

                                          Honnestly, I know that such discussions by mail or on a forum lead to nothing. This is very difficult to talk about something 'serious' for several reasons: 1) A part of the communication is missing: the only thing you see is text on a screen. So, misunderstanding somebody happens very easily. When you talk to somebody, there is much more to the conversion than just the words. 2) It is easier to write something that you don't really think just because you are a bit angry or had a bad day. You just type something on your keyboard and that's it. It's totaly different if you actually had that person in front of you. Perhaps that was said just as a joke, who knows. But I agree it's a bit playing with fire. I think you should simply let it go and stop it before it escalates too far. You know who you are and I can tell you that you are not a shame to your country, it is even the opposite :)

                                          Cédric Moonen Software developer
                                          Charting control [v1.4] OpenGL game tutorial in C++

                                          R Offline
                                          R Offline
                                          Rajesh R Subramanian
                                          wrote on last edited by
                                          #42

                                          Those two points were excellent pal. It made me think in a way that i hadn't.

                                          Cedric Moonen wrote:

                                          I can tell you that you are not a shame to your country, it is even the opposite [Smile]

                                          Thanks friend, those words were soothing. :)

                                          Please leave us our small pleasures, they are small, but they are ours! - Mycroft Holmes ^ .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups