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. supressing a unused variable warning

supressing a unused variable warning

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 Posters 8 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.
  • H Offline
    H Offline
    hyling
    wrote on last edited by
    #1

    Hi, How would I supress a warning for a certain variable which I know is unused? On other compilers I can use something like #pragma unused (variableName). Thanks Hua-Ying

    P G 2 Replies Last reply
    0
    • H hyling

      Hi, How would I supress a warning for a certain variable which I know is unused? On other compilers I can use something like #pragma unused (variableName). Thanks Hua-Ying

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      UNUSED(x); UNUSED_ALWAYS(y); UNREFERENCED_PARAMETER(z);


      "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!

      H 1 Reply Last reply
      0
      • P PJ Arends

        UNUSED(x); UNUSED_ALWAYS(y); UNREFERENCED_PARAMETER(z);


        "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!

        H Offline
        H Offline
        hyling
        wrote on last edited by
        #3

        Thanks! UNREFERENCED_PARAMETER(z); worked for me. Hua-Ying

        1 Reply Last reply
        0
        • H hyling

          Hi, How would I supress a warning for a certain variable which I know is unused? On other compilers I can use something like #pragma unused (variableName). Thanks Hua-Ying

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #4

          Another approach is the following:

          void function(type1 parm1,type2 /*parm2*/)
          {
          //...
          }

          Commenting out the parameter name in the argument list guarentees that the parameter isn't used, since there is no longer a definition for it (the compiler will issue an error message otherwise).


          Software Zen: delete this;

          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