ARM Technical Support Knowledge Articles


Applies to: C51 C Compiler



Is there a reason why va_list (in stdarg.h) is declared as "char *" and not as "char data *" if the stack is always in the data memspace? For this to work, it seems as if va_arg should be defined as follows:

#define va_arg(ap,t) (((t data *)ap)++[0])

Why isn't va_arg defined this way?


Although the STACK is in DATA space, the variables passed as arguments to a function are not always stored in DATA space (and they are only stored on the stack if the function is reentrant).

Function arguments are stored in fixed memory locations in DATA (small model), PDATA (compact model), or XDATA (large model). If the function is reentrant, the arguments are stored on the reentrant stack which is simulated and located in DATA, PDATA, or XDATA, again, depending on the memory model.

For these reasons, the macros used to access the additional arguments use generic pointers (char *) and not memory-specific pointers (data char *).

Article last edited on: 2004-06-07 08:14:41

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential