This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Formatting a string

Hello,

 

Hello,

I have a codec engine algo. For giving the user a human readable error message my UNIVERSAL_OutArgs contains a error string:

 

/* Output parameters */

#define SZ_STRING 20

typedef struct IMy_OutArgs {

IUNIVERSAL_OutArgs universalOutArgs;

char cvt_err_string[SZ_STRING];

} IMy_OutArgs;

 

Whats the best method to format this string on the DSP side (in myUniversal_process)? Is it okay to use sprintf?

 

C.

  • sprintf() is not an allowed fxn in an XDAIS alg (like an IUNIVERSAL alg) because it's not re-entrant.  If your alg and another both used sprintf(), trouble could arise.  This is documented in SPRU352 - http://www-s.ti.com/sc/techlit/spru352 - appendix B.1.

    Typically algs just return error codes via IUNIVERSAL_OutArgs.extendedError.

    If you really want to return a string, strcpy() is allowed in the list of fxns, so you could have a static copy of your error msgs in a lookup table and strcpy() them into your char buffer.

    Chris