AnsweredAssumed Answered

snprintf and sscanf issues upgrading from CW V6.4 to CW V10.4

Question asked by David Brooks on Oct 3, 2014
Latest reply on Oct 10, 2014 by David Brooks

Why won't snprintf and sscanf work correctly when porting working C code from CW6.4 to CW10.4? Processor is 5282. Automatic Library Configurations is being used: ewl, int_FP, int_FP, raw) . MQX is not used. Code compiles, but does not execute properly in “some” cases. In the case of sscanf, it does not like the format "%lf". I think it has something to do with defining _EWL_FLOATING_POINT_IO.

 

Also, changed "%lf" to "%f" with no success. The manuals indicate that by selecting int_FP on the CodeWarrior Librarian Settings page, the compiler will automatically select the proper files for inclusion into the project. However, it appears that neither Floating Point or Floating Point IO are defined. Do I need to recompile the library?

 

UPDATE: snprintf() issues were fixed by "getting back to the basics" by turning On "Require Function Prototypes" (which was not set in the CW6.4 Project) and then fixing all of the errors and warnings.

 

However, the sscanf() issue remains. The following call to sscanf() returns 0 with inValue=0.0. Stepping through library file scanf.c continues to indicate that _EWL_FLOATING_POINT_IO is not enabled despite numerous efforts to do so. I also wonder if scanf.c is the correc tfile to include. REF scanformat.c, scanformat_fp.c, etc.

 

#include <stdio.h>

 

int numChars = 0;

int numVars = 0;

char inText[64];

double inValue = 0.0;

 

numChars = GetLine(inText, sizeof(inText));

     After data entry in the above statement, inText[] = {'1','.','2','3',000000000000000...}

 

numVars = sscanf(inText, "%lf", &inValue);

Outcomes