Keil Logo

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 */
}
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.