Keil™, An ARM® Company

Cx51 User's Guide

MAXARGS Compiler Directive

Abbreviation None.
Arguments Number of bytes compiler reserves for variable-length argument lists.
Default MAXARGS(15) for small and compact models.

MAXARGS(40) for large model.
µVision Options — C51 — Misc controls.
Description 

The MAXARGS directive specifies the buffer size for parameters passed in variable-length argument lists of non-reentrant functions. This directive must be specified before the C function with the variable-length argument list.

Note

  • The MAXARGS directive specifies the total number of bytes that may be passed—not the maximum number of parameters.
  • The MAXARGS directive has no impact on the total number of bytes nor the maximum number of arguments that may be passed to reentrant functions.
Example 
C51 SAMPLE.C MAXARGS(20)

#pragma maxargs (4)  /* allow 4 bytes for parameters */
#include < stdarg.h >

void func (char typ, ...)  {
  va_list ptr;
  char c;  int i;

  va_start (ptr, typ);
  switch *typ)  {
    case 0:                     /* a CHAR is passed */
      c = va_arg (ptr, char);  break;
    case 1:                     /* an INT is passed */
      i = va_arg (ptr, int);  break;
  }
}

void testfunc (void)  {
  func (0, 'c');             /* pass a char variable */
  func (1, 0x1234);          /* pass an int variable */
}