tags:

views:

49

answers:

1

Say I have:

#define MY_MACRO(FOO) void FOO();

MY_MACRO(hi);
MY_MACRO(hey);
MY_MACRO(hello);

#undef MY_MACRO

I want the macros to be expanded by doxygen, which I am able to do by configuring it the right way:

ENABLE_PREPROCESSING   = YES
MACRO_EXPANSION        = YES
EXPAND_ONLY_PREDEF     = YES
EXPAND_AS_DEFINED      = MY_MACRO

This enables me to see the expanded result of the macros as documented APIs in the doxygen output (functions hi, hey, and hello). That is all good so far. But the problem is that, doxygen also documents MY_MACRO as a define. However, I do not want the clients of the API to know about MY_MACRO, since it is undefed and is not usable by them, and should not be visible to them.

I have EXTRACT_ALL = YES in my doxygen configuration and I do not want to change that. I have tried the following configuration without success:

PREDEFINED      = DOXYGEN_SKIP_FOR_USERS

With the following code:

#ifndef DOXYGEN_SKIP_FOR_USERS
#define MY_MACRO(FOO) void FOO();
#endif /*DOXYGEN_SKIP_FOR_USERS*/

MY_MACRO(hi);
MY_MACRO(hey);
MY_MACRO(hello);

#undef MY_MACRO

This hides the documentation of the define, but of course prevents the expansion, so I do not get the functions documented in the generated API.

I would appreciate your help.

+2  A: 

Supposing that MY_ is the prefix that you are using consistently in your code :) I would use the prefix MY__ (two underscores) for internal macros and then put something like

EXCLUDE_SYMBOLS        = MY__*

in the Doxygen configuration file.

Edit: the double underscore inside symbols is reserved for C++ (not for C). So if you want to be compatible with C and C++ you should choose some other type of convention. Unfortunately a leading underscore is reserved, too, so _MY_ wouldn't do neither.

Jens Gustedt
A note on the double underscore: Names containing a double underscore are reserved for use by the compiler. To avoid stepping on each others toes, it is best to avoid using a double underscore in your own identifiers.
Bart van Ingen Schenau
@Bart Do you have a citation handy? I thought it was only identifiers starting with a double underscore. (And global identifiers starting with an underscore at all, etc.)
llasram
@Bart and @llasram: I think that this double underscore rule is a C++ rule, not for C. (I didn't notice the C++ flag). But in any case for the purpose we are talking about here, one can easily figure out just some other, not too nasty, prefix.
Jens Gustedt
I don't see EXCLUDE_SYMBOLS in doxygen documentation at: http://www.stack.nl/~dimitri/doxygen/config.html
bugur
It works though!
bugur
@bugur: yes strange, that it is not documented there. But it appears and is documented in the default configuration file that doxygen produces.
Jens Gustedt
I created a bugzilla item on documentation.
bugur
@Jens and @llasram: The double underscore is indeed C++ only and is stated in clause 17.4.3.1.2 of the C++ standard. For me, the issue was worth commenting on, but not worth a downvote.
Bart van Ingen Schenau
@Bart: I never thought you would. For the double underscore, thanks for digging this out. It sounds reasonable for C++, it has to leave naming conventions for function name mangling. I will edit my answer, so people don't have to did through the comments.
Jens Gustedt