1

In my current project I'm trying to generate documentation with doxygen. However I have a problem with a variable. Somehow doxygen recognizes the variable as a function.

The code:

__xdata __at (0x0F00) volatile static unsigned char Programmed; /*!< an indicator if     the board is programmed or not, during init copied from flash to xram*/

/*! 
*   The main loop that does all the magic
*   besides the "compiler startup" _sdcc_external_startup (in HWInit.c) is called to handle some "urgent" init (disabling of the watchdog)
*/
void main(void){
    unsigned short int TempUSInt;
    //init the device.
    Init_Device();

Note about the code: the code is written for the SDCC compiler for a 8051 microcontroller. The __xdata __at () directive is a special instruction so the compiler knows that it has to place the data in a separate memory segment (called XDATA) at a predetermined location (address 0x0F00).

My probem is that doxygen recognizes the __at() as a function instead of a variable and thus overwrites the main() function.

Although there are ways to make doxygen ignore the __xdata __at () char Programmed statement this has as downside that the variable is ignored and thus not documented.

So is there anyone who knows how to get doxygen to recognize the __xdata __at () char Programmed as a variable instead of a function?

user2986756
  • 89
  • 1
  • 9

1 Answers1

2

My strategy would be to hide (define as empty) the compiler magic from doxygen with doxygen macros (untested; play around):

PREDEFINED = __xdata= \
             __at()=

You might also look at the docs for EXPAND_AS_DEFINED.

PS: Does your OS actually allow a void-returning main? If not, you should use int main(void).

Jens
  • 69,818
  • 15
  • 125
  • 179
  • That's it. Thanks for the quick answer. I need to mention that it also requires the settings `ENABLE_PREPROCESSING = YES` `MACRO_EXPANSION = YES` `EXPAND_ONLY_PREDEF = YES` the rest can be default – user2986756 Nov 13 '13 at 09:49
  • About the return of main(): I'm on a microcontroller with no OS. So if my main exits I have a big problem ;-). My main is essentially `void main(void){ while(1){} }`. This is total normal on microcontrollers. – user2986756 Nov 13 '13 at 10:01
  • +1 Neat approach; but it does force those other settings which may not be ideal in the general case. An alternative would be to surround just the `__xdata __at (0x0F00) ` preamble with `\cond` ... `\endcond` comments assuming the compiler is happy with breaking the xdata line. – Cheeseminer Nov 13 '13 at 10:54
  • @Cheeseminer It looks like your approach also works. Although I did keep a single line for the case: `/*!\cond XDATAIGNORE*/__xdata __at (0x0F00) /*!\endcond*/ volatile static unsigned char Programmed; /*!< ...*/`. The downside of this method is that the code has a messier "feel" to it. So I will be using the method by @Jens but this also works. – user2986756 Nov 14 '13 at 07:58