-
Enhancement
-
Resolution: Unresolved
-
Medium
-
Code Generation Tools
-
CODEGEN-9791
-
C2000_21.6.0.LTS
-
C2000_NEXT*
-
default
The internal RTS header file format.h has these lines ...
#ifndef __FORMAT_H #define __FORMAT_H #include <stdarg.h> #if defined (MINIMAL) #define FORMAT_CONVERSION_BUFSIZE 32 #elif defined (__MSP430__) #define F_CONVERSION_BUFSIZE 100 #define FLOAT_VALUE_BUFSIZE 32 #else /****************************************************************************/ /* The minimum max conversion size to be C89 compliant is 509 */ /****************************************************************************/ #define F_CONVERSION_BUFSIZE 510 #define FLOAT_VALUE_BUFSIZE 100 #endif
The RTS source file _printfi.c has these lines ...
/**************************************************************************/ /* Full printf definition */ /**************************************************************************/ #define _PRINTFI __TI_printfi #include "_printfi_template.c" #undef _PRINTFI /**************************************************************************/ /* No float printf definition */ /**************************************************************************/ #define _PRINTFI __TI_printfi_nofloat #define NOFLOAT #include "_printfi_template.c" #undef NOFLOAT #undef _PRINTFI /**************************************************************************/ /* Minimal printf definition */ /**************************************************************************/ #define _PRINTFI __TI_printfi_minimal #define MINIMAL #include "_printfi_template.c" #undef MINIMAL #undef _PRINTFI
Note how _printfi_template.c is included three times. The file _printfi_template.c includes format.h. Because of the inclusion guards, this definition ...
#if defined (MINIMAL) #define FORMAT_CONVERSION_BUFSIZE 32
... is never seen. Even for --printf_support=minimal, FORMAT_CONVERSION_BUFSIZE is 510. Therefore this local buffer in the function _printfi_minimal ...
char fld[FORMAT_CONVERSION_BUFSIZE];
... is 510 bytes, and not 32. This means _printfi_minimal uses much more stack space than required.