声明:
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. |
µ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
|
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 模型。 |
µVision | Options — C51 — Misc controls. |
描述 | MAXARGS 伪指令指定传递给非重入函数的可变长度的参数的缓冲大小。这个伪指令必须在具有可变长度参数列表的C函数前指定。 注意
|
示例 | 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 */
}
|