You are not logged in.
Pages: 1
GCC 6 is very verbose in reporting unused variables, which I find good. However, this poses some problems when using Doxygen. For example, I have this definition inside one of my headers:
/*! @brief Initialization method.
*
* Implementations of this method can create data branches in #tree. Histograms and graphs can also
* be initialized here. The number of the current processing pass can also be specified to
* allow different configurations for different passes.
*
* @param tree The ROOT tree where branches can be created.
* @param pass The number of the current pass (0 = first pass, 1 = second pass etc.)
* @return true if the initialization procedure has been successful, false otherwise.
*/
virtual bool Initialize(TTree *tree, int pass = 0) {
return true;
}
This is a default void implementation for a mother class which is eventually overridden by children. GCC gives warnings about tree and pass being unused; if I remove the variable names so that GCC is happy then Doxygen gets angry:
/home/mori/DQM/Core/include/DQProcessor.h:52: warning: argument 'tree' of command @param is not found in the argument list of DQM::DQProcessor::Initialize(TTree *, int=0)
/home/mori/DQM/Core/include/DQProcessor.h:52: warning: argument 'pass' of command @param is not found in the argument list of DQM::DQProcessor::Initialize(TTree *, int=0)
Is there a way, without silencing GCC's warning about unused variables, to solve this issue? Thanks.
Offline
Use a diagnostic pragma?
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Ehm... can you elaborate a bit, Eschwartz? I'm a Doxygen noob and I'm still learning how to use it. Thanks!
Offline
I find it weird that you get warnings about this, I can't remember warnings about unused parameters from back when I fiddled with C++.
Is there a reason why you're implementing the virtual function? If the function is eventually going to overridden, why not make it a pure virtual function? Sounds like you're working on an abstract base class to me.
Offline
It's GCC, not Doxygen.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Web search also gives suggestions like http://stackoverflow.com/questions/3599 … -in-c-code
With C++17 you get an attribute in the language standard:
virtual bool Initialize([[maybe_unused]] TTree *tree, [[maybe_unused]] int pass = 0) {
Offline
It seems there's plenty of solutions, portable and not. I'll give a look and try to find the best suited for me. Thanks to everybody.
Offline
I usually just define something like
#define VAR_UNUSED(x) (void)x;
and use it like this
virtual bool Initialize(TTree *tree, int pass = 0) {
VAR_UNUSED(tree)
VAR_UNUSED(pass)
return true;
}
Tested it with GCC, Clang, mingw-w64.
Offline
Pages: 1