mardi 28 août 2018

Visual Studio equivelent of gcc __attribute__((unused)) in c++11 (or lower)?

I am trying to write a macro to use suppress unused variable warnings when the user wants them (e.g. in derived classes when you have not implemented the whole class yet). I know that I can remove the variable name... but to make it clear I would prefer a macro).

So far I have this:

#ifdef WIN32
    #define UNUSED(x) x
#else
    #define x __attribute__((unused))
#endif

Used like:

void test_fn(int UNUSED(test_var)) {...}

I saw this post: suppressing-is-never-used-and-is-never-assigned-to-warnings-in-c-sharp, but it gave me a result that I can't really use (multiline #pragmas).

So my question is, is there a MSVS equivalent of the __attribute__((unused))? - i.e. on the same line?

Aucun commentaire:

Enregistrer un commentaire