|ARM Technical Support Knowledge Articles|
Applies to: C251 C Compiler
Information in this article applies to:
I understand that the total number of bytes of arguments you can pass to a function using a variable-length argument list is limited. The limit is just 40 bytes for the LARGE memory model. That amounts to ten 4-byte arguments. I need to pass more than that to the scanf function.
In my application I must convert a very long command string that contains 16 HEX values. The sscanf invocation appears as follows:
args = sscanf(cmd_str, "%*s %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", &cdc_cmd, &values, &values, &values, &values, &values, &values, &values, &values, &values, &values, &values, &values, &values, &values, &values, &values);
When I compile this module I receive the following error message:
ERROR C187: 'SSCANF': SIZE OF ACTUALS EXCEEDS 'MAXARGS'
How can I overcome this problem?
A simple solution to your problem is to use the reentrant version of the sscanf function. You may do this by adding the #pragma function statements around the stdio.h include file. For example:
#pragma functions (reentrant) #include <stdio.h> /* Standard I/O prototypes */ #pragma functions (static)
A problem with this solution is that your application may use a large amount of the hardware stack.
To avoid this, you can extend the parameter area of the static scanf function as follows:
; Extended SSCANF Parameter Space $IF (LARGE) ?XT?sscanf SEGMENT XDATA RSEG ?XT?sscanf DS 40 ; additional 40 Bytes for Parameter $ELSE $IF (TINY OR SMALL) ?DT?sscanf SEGMENT DATA RSEG ?DT?sscanf DS 40 ; additional 40 Bytes for Parameter $ELSE ?ED?sscanf SEGMENT EDATA RSEG ?ED?sscanf DS 40 ; additional 40 Bytes for Parameter $ENDIF $ENDIF END
Article last edited on: 2005-08-03 10:20:58
Did you find this article helpful? Yes No
How can we improve this article?