First of all, sorry if this is an obvious question, but I'm rather new to C++. Also, this code is not originally mine, but I am trying to clean it up.
I'm looking for a compiler independent way to surpress warnings (preferably) for a specific line. I've got the following code:
int MPtag::state_next( int i, int s ){
#if NGRAMS==2
return s+1;
#elif NGRAMS==3
return tag_at(i,0) * num_tags + s+1;
#elif NGRAMS>=4
return tag_at(i,-1) * num_tags*num_tags + tag_at(i,0)*num_tags + s+1;
#endif
}
NGRAMS is currently set to 2.
G++ gives me a warning (with the appropriately paranoid options of course) that the parameter "i" is unused. While this is technically true, it is not always the case. I've thought about commenting out the variable name, but then if NGRAMS were to be changed it would produce a compiler error until uncommented; which is undesirable.
The oldest answer for related question proposes a macro, but another poster say that it is not compiler independent. I've read about #pragma warning
but AFAICT that is VS C++ thing. Is there even a proper way to do this?