The Linux Page

Doxygen does not generate documentation for my C functions (or any global function)

As I write programs, mainly in C++, I document them using the Doxygen tool. This is a very powerful parser that is capable to finding functions, variables, macros, and many other things in the source code and attach the corresponding documentation to those functions, variables, macros, etc.

This is extremly practical when creating large projects or libraries that you want to share with others.

One problem though, by default it seems like global functions (and thus C functions) and variables do not make it to the documentation, when C++ classes work fine.

There are two potential issues:


The EXTRACT_ALL flag is set to NO. This is the default and it is expected to remain set to NO. By setting the flag to YES you already get many more definitions in your output but still not everything.

However, setting this to YES has some side effects that are often unwanted. Therefore I suggest you instead use the following trick.


Files are considered private by default. This means files that do not have the @file declaration (or \file) are ignored and not included in your Doxygen output, except for members of C++ classes.

Yes! It is that simple. Edit your C file, go anywhere you want, and add @file in a comment, probably with a @brief description too:

@brief This file is marvelous.

Note that the @file accepts the name of the filename but it defaults to the expected name of the file you're documenting so it is not required. Although you could define all your files in one main file in which case the filename is required. Also, you could define a generated file in another (i.e. @file generated.file @brief blah blah blah...)

This way you'll get all the Doxygen will not skip the documentation your wrote for your C files and any C++ global funtion, variable, etc.

Re: Doxygen does not generate documentation for my C ...

This really helped, thanks!

Re: Doxygen does not generate documentation for my C ...

Yes... Really difficult to find such a trick! I noticed just yesterday that a C++ library would not make it at all until I had at least one @file, then most everything started happening. Very strange!

Re: Doxygen does not generate documentation for my C ...

Thank you!! I can't believe they didn't add this in the Doxygen tutorial.