Is there a good program to generate documentation from C source code? For example, similar to javadoc, if I could write the documentation about the parameters and then create html documentation from the source code.

/* size_t: number of bytes of memory to allocate */
void *malloc(size_t nbytes) {
    if (nbytes == 0) {
        return NULL;

#if   STRATEGY == 1
    return malloc_first(nbytes);
#elif STRATEGY == 2
    return malloc_best(nbytes);
#elif STRATEGY == 3
    return malloc_worst(nbytes);
#elif STRATEGY == 4
    return malloc_quick(nbytes);

Doxygen is very much the standard for this and has been for years - you can annotate your functions and parameters to document them and it will extract:

  • The annotated documentation
  • The function & class signatures
  • Called functions & calling functions,
  • Lots more

It can be run from the command line but there is also a DoxyWizard to configure a project.

It can generate a large number of formats of documentation including htlm, htmlhelp, man, etc.

It can construct very nice documentation and can also add very good diagrams if you have GraphViz installed.

It can parse C, C++, Java, (Corba and Microsoft) Java, Python, VHDL, PHP IDL, C#, Fortran, TCL, Objective-C 2.0, and to some extent D sources.

It is Free, Gratis & Open Source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.