unused variables

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: unused variables

Postby YaronCT » Thu Aug 27, 2015 15:11

Thanx!

User avatar
Ident
CEGUI Team
Posts: 1868
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: unused variables

Postby Ident » Sun Sep 06, 2015 19:58

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.
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: unused variables

Postby YaronCT » Mon Sep 07, 2015 07:09

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.

User avatar
Ident
CEGUI Team
Posts: 1868
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: unused variables

Postby Ident » Mon Sep 07, 2015 07:14

I approve it only for usage in the two cases you mentioned. In any other case the parameter identifier should be commented out.
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: unused variables

Postby YaronCT » Mon Sep 07, 2015 07:19

Ok, that's what I meant.


Return to “CEGUI Library Development Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest