I am trying to create documentation using Doxygen to emulate C templates without much success. I hope someone knows how to do macro cheating in the doxygen preprocessor? I already tried turning on "MACRO_EXPANSION" without any luck.
EDIT: The most denatured form of this question would be: "How can I get Doxygen to process the #include preprocessor directive in the same way that the C preprocessor does?"
I have the following code in the "test" folder (a very contrived example):
templates.h
#ifndef TEMPLATES_H_ #define TEMPLATES_H_ #define CAT(X,Y) X##_##Y #define TEMPLATE(X,Y) CAT(X,Y) #endif
test.h
#ifndef TEST_H_ #define TEST_H_ #include "templates.h" #ifdef TEST_T #error "TEST_T cannot be defined prior to this compilation step" #endif #define TEST_T uint8_t #include "test_template.h" #undef TEST_T #define TEST_T uint16_t #include "test_template.h" #undef TEST_T #endif
test_template.h
#ifdef TEST_T #include "templates.h" TEST_T TEMPLATE(sum,TEST_T)(TEST_T a, TEST_T b); #endif
test.c
#include "test.h" #ifdef TEST_T #error "TEST_T cannot be defined prior to this compilation step" #endif #define TEST_T uint8_t #include "test_template.c" #undef TEST_T #define TEST_T uint16_t #include "test_template.c" #undef TEST_T
test_template.c
#ifdef TEST_T TEST_T TEMPLATE(sum,TEST_T)(TEST_T a, TEST_T b) { return a + b; } #endif
In my doxygen configuration file:
test.cfg
# Doxyfile 1.8.13 PROJECT_NAME = "Test" OUTPUT_DIRECTORY = "docs_test" TAB_SIZE = 3 OPTIMIZE_OUTPUT_FOR_C = YES INPUT = "../test" RECURSIVE = YES MACRO_EXPANSION = YES
However, the template versions of the sum * function are missing from the doxygen documentation (.h or .c); for example, test.h below (although I would also be happy if it appeared in test_template.h instead):

Any thoughts?