C51: LIMITS ON FUNCTIONS WITH VARIABLE-LENGTH ARGUMENT LISTS
Can you clarify the requirements on the number of bytes passed to functions with variable-length argument lists (like the printf function) when using the C51 compiler?
Programs are created using C51 pass arguments in fixed memory locations. Arguments are not passed on the stack. For this reason, there are some limitations placed on functions, like printf, that utilize a variable-length argument list (vararg).
You may use the MAXARGS compiler directive to change the number of bytes reserved. Note, however, that large numbers will rapidly consume memory in SMALL and COMPACT memory models. MAXARGS has no influence on library functions which are using variable argument lists (example: printf, scanf...).
The number of bytes of reserved space refers to how many bytes the arguments to the function require. For example:
printf ("This is test # %d. %s\n", (int) i, s);
takes three (3) arguments: the format string, the integer i, and the char pointer s. So, the above printf function call needs 8 bytes for its arguments as shown below.
3 bytes = Format String (this is treated like a generic character pointer (char *)). 2 bytes = Integer (int i). 3 bytes = Character Pointer (char *s). --------- 8 bytes = Number of argument bytes
Note that the requirements and limitations placed on variable-length argument lists do not apply to reentrant functions.
Last Reviewed: Tuesday, November 6, 2012
of your data.