So I've got a compiler bug with their low level _fconvert() function that the vendor has marked as low priority, but the effect is that the embedded system will crash if I send a NaN value to a printf() style function. I'd like to write a wrapper for sprintf() that parses for floats, and if they are NaN values, they get replaced by a macro value. I think I get the basics on how to pass the variable parameter list, but not how to parse/replace. Can anyone help me on this?
int no_nan_sprintf(char *target_str, const char *format, ...)
{
    va_list args;
    va_start(args, format);
    //need help here, something like
    int idx;
    for (idx = 0; idx < sizeof(args); idx++)
    {
        if (isnan(args[idx]))
        {
            args[idx] = NAN_SUBSTITUTE_VALUE;
        }
    }
    //this should be tha call I want to make to sprintf
    sprintf(target_str, format, args);
    va_end(args);
}                  /* no_nan_sprintf */
 
    