How do I get Doxygen to expand macros from include files? - c++

I have a number of multiline macros defined in a file called macros.h. In my doxyfile, I've got
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = NO
yet Doxygen still will not expand the macros in any source file that includes macros.h. I ran "doxygen -d Preprocessor doxyfile" to see the output of the preprocessor, and it outputs messages like:
#include macros.h: not found or already included! skipping...

You've told your compiler about your include path, but you haven't told doxygen. So it tries to open "macros.h" and gets a file-not-found error.
You need to properly set INCLUDE_PATH in your Doxyfile.

#Ben: Have you actually gotten INCLUDE_PATH to work?
I understand the theory. I have set up the INCLUDE_PATH as explained (in both absolute and relative forms) but to no avail. I have set INCLUDE_FILE_PATTERNS to *.h. Nonetheless, when processing my .cpp files Doxygen finds all of the headers in the INPUT directory yet fails to find any headers in my lib/ subdirectory.
The only solutions I have found are:
1) Create a symbolic link within the INPUT directory to each header in its lib/ subdirectory. This is ugly and ungeneralizable.
2) Set the RECURSIVE tag to YES. This is undesirable because now the entire contents INPUT's tests/ subdirectory get added to the generated documentation.
I am inclined to believe that INCLUDE_PATH functionality is simply broken (at least in version 1.7.1 that I am running).

Related

Exclude Qt from doxygen header dependency graph

I have a Qt-based C++ project and a Doxyfile to generate a documentation website for it. I like the include dependency graphs enabled by INCLUDE_GRAPH and INCLUDED_BY_GRAPH. Sometimes, however, they get very cluttered by all the Qt headers included. (How) can I only display my own files there?
I tried adding EXCLUDE = /usr/include/qt, to no avail. This question has no answer, either.
Bit outdated but I have found the answer. Set up the INPUT_FILTER (under Expert/Input in doxywizard) to
sed -e "s:#include <Q.*>:// REMOVED:g"
This will preprocess any file that Doxygen analyses and replace all #include <QAnything> with comment // REMOVED.

Doxygen Not Documenting c++ Source Files

I've set the INPUT field to my source directory, and my FILE_PATTERNS field contains all the names of my source files. I've tried explicitly naming the sources and using wildcards, and it only generates documentation for my header files.
Setting the EXTRACT_ALL field to "YES" fixes this.

Generating documentation with doxygen

I would like to generate documentation for C++ files with doxygen. Everything is good when all the *.h and *.cpp files are stored in one folder. Then I type
doxygen -g doxygenfile
and then
doxygen doxygenfile
After all this I have a latex folder and an html folder. Everything is good. The problem is when these files *.h *.cpp are stored in different locations, e.g.: *.h in H folder *.cpp in CPP folder and so on. Could somebody tell me how to generate the documentation in this case?
If you want a GUI to tweak how Doxygen works you can use doxywizard and open the generate Doxyfile.
In order to make doxygen look into the subdirectories you can change in the Doxyfile this line
RECURSIVE =
with
RECURSIVE = YES
Edit: As bornruffians pointed out, Doxygen looks for the source files in the directories specified in the INPUT setting (always in the Doxyfile). So you can specify each directory in the INPUT tag by writing something like
INPUT = "src/CPP" "src/H"
and turn off the RECURSIVE tag. You can also put single files as values for the INPUT tag.

How To Get g++ to list paths to all #included files

I would like to have g++/gcc tell me the paths to everything non-system it is #include-ing in C++ build. Turns out, that is a tough search as Google mus-interprets it about ten different ways.
I want these filenames and paths so I can add them to the search path for Exuberant CTAGS. We have a huge project and if I use ctags on the whole thing it takes about half an hour to generate the tags file and nearly as long for the editor to do a look-up.
We use CMakeLisats to do the compiling. If there is a directive I can paste into the CMakeLists.txt, that would be extra wonderfulness.
I don't really need the default paths and filenames, Johnathan Wakely gave a good tool for that here. I think that pretty much covers the fact that this is a cross compile job. I don't need the cross-system files either.
Try gcc or g++ with the -H option (to the preprocessor part of it). From the doc:
-H
Print the name of each header file used, in addition to other normal activities. Each name is indented to show how deep in the ‘#include’ stack it is. Precompiled header files are also printed, even if they are found to be invalid; an invalid precompiled header file is printed with ‘...x’ and a valid one with ‘...!’ .
It tells you all the headers which are included. You may filter out (with grep -v or awk) those that you don't want.
You could also consider developing your GCC plugin to register these headers somewhere (e.g. in your sqlite database), perhaps inspired by this draft report, or the CHARIOT or DECODER European projects. You could also consider using, or extending, the Clang static analyzer.
In contrast to the -M options suggested in Oliver Matthews' answer, it does not tell you more (but gives all the included files).
You need to invoke g++ with the -M option.
From the manual:
Instead of outputting the result of preprocessing, output a rule
suitable for make describing the dependencies of the main source file.
The preprocessor outputs one make rule containing the object file name
for that source file, a colon, and the names of all the included
files, including those coming from -include or -imacros command line
options.
It's worth reading the manual to consider the other -M sub options (-MM and -MF in particular may be of use).

Doxygen won't find headers in subdir

I'm documenting a C++ library's header files with Doxygen. In the Doxyfile, I defined
INPUT = include/
in the hopes that Doxygen would then generate documentation for all the header files in include/Foo, but it doesn't: only the index.html is generated. I can set INPUT to include/Foo, but then the documentation lists the headers with their basenames (Reader.hh), while I want clients to include the headers as Foo/Reader.hh etc.
How can I get Doxygen to look within the subdirectory?
Have you set RECURSIVE to YES?
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = YES
it's in the Doxyfile (here line 608, might be sligthly different for you)