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. General Programming
  3. C / C++ / MFC
  4. Warning Level 4

Warning Level 4

Scheduled Pinned Locked Moved C / C++ / MFC
question
13 Posts 5 Posters 1 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.
  • J Joel Holdsworth

    No it's not a problem, just asking you if your function prototype has a mistake in it or not. I think you can get it to keep quiet by doing somthing like this:

    void Function(int foo)
    {
    foo; // By putting this here, C4100 should be surpressed
    }

    Joel Holdsworth Wanna give me a job this summer? Check out my online CV and project history[^] - now available in MSWord format![^]

    S Offline
    S Offline
    S Douglas
    wrote on last edited by
    #3

    Joel Holdsworth wrote: I think you can get it to keep quiet by doing somthing like this: void Function(int foo) { foo; // By putting this here, C4100 should be surpressed } I had started doing that then thought um that might be bad, let’s see what every one else says. All of the function prototypes that I have created myself are fine. It mostly just the message over rides that cause this problem. Thanks much Joel -------------------------------

    J 1 Reply Last reply
    0
    • S S Douglas

      Joel Holdsworth wrote: I think you can get it to keep quiet by doing somthing like this: void Function(int foo) { foo; // By putting this here, C4100 should be surpressed } I had started doing that then thought um that might be bad, let’s see what every one else says. All of the function prototypes that I have created myself are fine. It mostly just the message over rides that cause this problem. Thanks much Joel -------------------------------

      J Offline
      J Offline
      Joel Holdsworth
      wrote on last edited by
      #4

      Yeah you just rewminded me the other way to deal with the problem (probably more efficiant too) i this. Say my function has to be have the parameters WPARAM followed by LPARAM, you don't have to give these names:

      int Function2(WPARAM, LPARAM param2)
      {
      param2 += 6; // We're using param2
      }

      You see the WPARAM is still present in the parameter list, but is not referenced at all. I think the optimiser should reduce the two methods to producing the same code, but this way is a little more elegant. Joel Holdsworth Wanna give me a job this summer? Check out my online CV and project history[^] - now available in MSWord format![^]

      S 1 Reply Last reply
      0
      • J Joel Holdsworth

        Yeah you just rewminded me the other way to deal with the problem (probably more efficiant too) i this. Say my function has to be have the parameters WPARAM followed by LPARAM, you don't have to give these names:

        int Function2(WPARAM, LPARAM param2)
        {
        param2 += 6; // We're using param2
        }

        You see the WPARAM is still present in the parameter list, but is not referenced at all. I think the optimiser should reduce the two methods to producing the same code, but this way is a little more elegant. Joel Holdsworth Wanna give me a job this summer? Check out my online CV and project history[^] - now available in MSWord format![^]

        S Offline
        S Offline
        S Douglas
        wrote on last edited by
        #5

        Yea that’s how I send messages when I don’t need the first param (WPARAM). It’s the params from over ridded messages that’s causing the problems. -------------------------------

        1 Reply Last reply
        0
        • S S Douglas

          ::Stupid Question Alert:: Compiling my application with warning level 4, I get a fair number of “warning C4100: (param name here) unreferenced formal parameter”. Is this something I should concern myself with or just ignore it? It was helpful in catching a couple of variables that where declared but unused. -------------------------------

          J Offline
          J Offline
          Jack Puppy
          wrote on last edited by
          #6

          I've used void Function(int param1, int param2) { UNREFERENCED_PARAMETER(param2); } and void Function(int param1, int /*param2*/) { } I think there's another macro, can't remember it offhand.

          :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

          S B 2 Replies Last reply
          0
          • J Jack Puppy

            I've used void Function(int param1, int param2) { UNREFERENCED_PARAMETER(param2); } and void Function(int param1, int /*param2*/) { } I think there's another macro, can't remember it offhand.

            :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

            S Offline
            S Offline
            S Douglas
            wrote on last edited by
            #7

            Jack Squirrel wrote: void Function(int param1, int param2) { UNREFERENCED_PARAMETER(param2); } I like that one. Pretty clear that, that param is not used. -------------------------------

            1 Reply Last reply
            0
            • J Jack Puppy

              I've used void Function(int param1, int param2) { UNREFERENCED_PARAMETER(param2); } and void Function(int param1, int /*param2*/) { } I think there's another macro, can't remember it offhand.

              :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

              B Offline
              B Offline
              Bob Stanneveld
              wrote on last edited by
              #8

              Jack Squirrel wrote: I think there's another macro, can't remember it offhand. MFC's macros: "UNUSED" and "UNUSED_ALWAYS" will do that trick for you too :-D I also got the blogging virus..[^]

              1 Reply Last reply
              0
              • S S Douglas

                ::Stupid Question Alert:: Compiling my application with warning level 4, I get a fair number of “warning C4100: (param name here) unreferenced formal parameter”. Is this something I should concern myself with or just ignore it? It was helpful in catching a couple of variables that where declared but unused. -------------------------------

                J Offline
                J Offline
                jmkhael
                wrote on last edited by
                #9

                This is the best way thought void Function(int param1, int /*param2*/) { } Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                S 1 Reply Last reply
                0
                • J jmkhael

                  This is the best way thought void Function(int param1, int /*param2*/) { } Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                  S Offline
                  S Offline
                  S Douglas
                  wrote on last edited by
                  #10

                  Papa wrote: void Function(int param1, int /*param2*/) { } Yea know some how I bet your correct. Anyone else know for sure? Thx Much -------------------------------

                  J 1 Reply Last reply
                  0
                  • S S Douglas

                    Papa wrote: void Function(int param1, int /*param2*/) { } Yea know some how I bet your correct. Anyone else know for sure? Thx Much -------------------------------

                    J Offline
                    J Offline
                    jmkhael
                    wrote on last edited by
                    #11

                    The bug slayer, John Robbins, in his Debugging Applications for Microsoft .NET and Microsoft Windows (Great book btw) Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                    S 1 Reply Last reply
                    0
                    • J jmkhael

                      The bug slayer, John Robbins, in his Debugging Applications for Microsoft .NET and Microsoft Windows (Great book btw) Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                      S Offline
                      S Offline
                      S Douglas
                      wrote on last edited by
                      #12

                      Sounds good. Now that I’m at home and free to wander the net I found an article at http://msdn.microsoft.com/msdnmag/issues/05/05/CAtWork/default.aspx[^] Which comments on this very subject. They say it doesn’t really matter. I’m inclined to think that commenting the section out is a "little" cleaner way to go about it (after some experimentation). -------------------------------

                      J 1 Reply Last reply
                      0
                      • S S Douglas

                        Sounds good. Now that I’m at home and free to wander the net I found an article at http://msdn.microsoft.com/msdnmag/issues/05/05/CAtWork/default.aspx[^] Which comments on this very subject. They say it doesn’t really matter. I’m inclined to think that commenting the section out is a "little" cleaner way to go about it (after some experimentation). -------------------------------

                        J Offline
                        J Offline
                        jmkhael
                        wrote on last edited by
                        #13

                        I know that these macros often resolve to param = param; which is a junk code just to reference the param. The commenting of the param just instruct the compiler to *not see* the param in order to skip the warning Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                        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