Game Development Community

Code Question

by William Todd Scott · in Torque Game Engine Advanced · 08/18/2007 (6:19 pm) · 3 replies

Hi,

Sorry for the obscure title, but I wasn't sure what to categorize this as....

I am seeing code like this in different spots in the engine:

ConsoleMethod( GuiCanvas, setContent, void, 3, 3, "(GuiControl ctrl)"
              "Set the content of the canvas.")
{
   object;
   argc;

   GuiControl *gui = NULL;
   if(argv[2][0])
   {
      if (!Sim::findObject(argv[2], gui))
      {
         Con::printf("%s(): Invalid control: %s", argv[0], argv[2]);
         return;
      }
   }

   //set the new content control
   Canvas->setContentControl(gui);
}

In particular the first two lines of the function with object and argc.

Can someone tell me what these lines are doing? To be honest, I'm not really sure why that is even valid C++ syntax, so any enlightment is helpful!

Thanks
Todd

#1
08/18/2007 (6:30 pm)
You don't actually need them. You should be able to safely delete them. I believe they are there to silence some compiler warnings about undefined variables.
#2
08/18/2007 (6:43 pm)
Actually they supress 'unused variable' warnings from compilers, not undefined variables. It's valid C++ syntax because it's just an expression. For more than you ever wanted to know about the ISO/IEC C++ grammar, look here.
#3
08/18/2007 (7:19 pm)
Cool.
Thanks guys.
Todd