2016-03-30 9 views
1

Kurzversion

nicht verwendeten Funktionsparameter Umgang

Um den Compiler aus der Aufnahme eine Warnung über nicht verwendete Variablen definiere ich das Makro UNUSED zu verhindern, wie:Doxygen: mit „nicht verwendet“ Makro

UNUSED(x)=x __attribute__((__unused__)) 

Dieses Makro dann verwendet wird, in einigen Prototypen Funktionen, zum Beispiel:

void ext(int foo, int UNUSED(bar)) 

Allerdings ist doxygen unglücklich darüber und gibt einige Warnungen:

/tmp/sandbox/main.cpp:13: warning: argument 'bar' of command @param is not found in the argument list of Dummy::ext(int foo, intUNUSEDbar) 
/tmp/sandbox/main.cpp:13: warning: The following parameters of Dummy::ext(int foo, intUNUSEDbar) are not documented: 
    parameter 'UNUSED' 

Wie soll ich doxygen sagen, um das UNUSED Makro zu ignorieren?

Lange Version

Ich habe einen Code, der wie folgt aussieht:

#include <iostream> 

class Dummy 
//! Dummy class 
{ 
public : 

    //!Dummy function 
    /** 
    * \param foo First variable 
    * \param bar Second variable 
    */ 
    void ext(int foo, int UNUSED(bar)) 
    { 
     std::cout << "foo = " << foo << std::endl; 
    } 
}; 


//!Main function 
int main(void) 
{ 
    Dummy MyDummy; 
    MyDummy.ext(1, 2); 
    return 0; 
} 

ich es kompilieren durch den Aufruf:

g++ -D 'UNUSED(x)=x __attribute__((__unused__))' main.cpp 

die Standard doxygen Konfigurationsdatei Doxyfile I genannt zu generieren Geben Sie ein:

doxygen -g 

Schließlich wird die Dokumentation zu erzeugen, I ein:

doxygen Doxyfile 

letzteren Befehl gibt die folgende Warnung:

/tmp/sandbox/main.cpp:13: warning: argument 'bar' of command @param is not found in the argument list of Dummy::ext(int foo, intUNUSEDbar) 
/tmp/sandbox/main.cpp:13: warning: The following parameters of Dummy::ext(int foo, intUNUSEDbar) are not documented: 
    parameter 'UNUSED' 
+0

Haben Sie sich den Preprozessor-Teil des Handbuchs angesehen? Vielleicht könnte ein PREDEFINED in der Doxyfile von UNUSED (x) helfen – albert

+0

Ich habe gerade einen Blick auf [doxygens Dokument zur Vorverarbeitung] geworfen (http://www.stack.nl/~dimitri/doxygen/manual/preprocessing.html): tatsächlich Es ist alles dort erklärt! Danke für den Tipp ! –

Antwort

2

folgenden Anweisungen vom doxygen documentation, die Doxyfile modifizieren, so dass sie die folgenden Parameter aufweist :

#Doxygen will run its own preprocessor before parsing the file 
ENABLE_PREPROCESSING = YES 

#The Doxygen preprocessor will not only define the macros (default 
#behaviour) but also expand them 
MACRO_EXPANSION  = YES 

#The Doxygen preprocessor will only expand the macros that are listed in 
#the PREDEFINED setting. Any other macro will merely be defined, and not 
#expanded. 
EXPAND_ONLY_PREDEF  = YES 

#The Doxygen preprocessor will replace any occurrence of the UNUSED 
#macro by its argument 
PREDEFINED    = UNUSED(x)=x 

Nach diesen Änderungen unter Berufung auf doxygen Doxyfile keine längere Warnungen.