CX51 用户手册----MAXARGS 伪指令

声明:

1、本翻译仅供个人学习使用,本人没有提供技术支持的义务,也不承担由此引发的任何后果。

2、请勿用于商业用途。

3、英文来自:http://www.keil.com/support/man/docs/c51/。

4、欢迎大家共同与我交流探讨(290207203@qq.com)。

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 */
}

MAXARGS 编译器伪指令

缩写

None.

参数

编译器为可变长度参数列表预留的字节长度。

缺省

MAXARGS(15) 对应small 和 compact 模型。
MAXARGS(40) 对应 large 模型。

µVision

Options — C51 — Misc controls.

描述

MAXARGS 伪指令指定传递给非重入函数的可变长度的参数的缓冲大小。这个伪指令必须在具有可变长度参数列表的C函数前指定。

 注意

  • MAXARGS 伪指令指定最大传递的字节数,而不是最大参数个数。
  • MAXARGS 伪指令不影响传递给重入函数的整个字节数及最大参数个数。
示例
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 */
}







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值