Page 2 of 2

Re: unused variables

Posted: Thu Aug 27, 2015 15:11
by YaronCT
Thanx!

Re: unused variables

Posted: Sun Sep 06, 2015 19:58
by Ident
Btw isn't

Code: Select all

void func(AwesomeClass& /* param1 */)
{
   // Some code that doesn't use param1
  ...
}

enough to suppress the warning for practially all compilers?

If yes then i absolutely oppose introducing the macro which requires to have an additional line for each function for each parameter. Also the above solution is already done in CEGUI in some instances.

Re: unused variables

Posted: Mon Sep 07, 2015 07:09
by YaronCT
Ident: This will work for most of the cases, and I have no objection using it. However, there are still 2 cases where this won't work, and then I suggest still using a macro:

1) When the unused variable is not a parameter. Say it's a local variable, e.g.

Code: Select all

bool is_success(myFunc());
assert(is_success)


In Release build you'll get a warning that "is_success" is undefined.

2) When the variable is only used in a preprocessor conditional block:

Code: Select all

void myFunc(int myVar)
{
    #if defined SOMETHING
        cout << myVar;
    #endif
}


Which with the macro will become:

Code: Select all

void myFunc(int myVar)
{
    #if defined SOMETHING
        cout << myVar;
    #else
        CEGUI_UNUSED(myVar);
    #endif
}


Plz tell me if u approve this.

Re: unused variables

Posted: Mon Sep 07, 2015 07:14
by Ident
I approve it only for usage in the two cases you mentioned. In any other case the parameter identifier should be commented out.

Re: unused variables

Posted: Mon Sep 07, 2015 07:19
by YaronCT
Ok, that's what I meant.