This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sscanf() problems


On 12/02/2014 12:21 PM, Steffen Wolfer wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear all,

I'm having the following, interesting problem using Newlib's sscanf().
Trying to read an IP address from a string with the following code
snippet:

void read_ipaddr()
{
   char *str;
   uint8_t a, b, c, d;
   int res;

   // This function returns a pointer to the
   // string that represents the IP address
   get_str( &str );

   res = sscanf( str, "%" SCNu8 ".%" SCNu8 ".%" SCNu8 ".%" SCNu8,
                 &a, &b, &c, &d );

   ...
}

As explained by others, the reason for the behavior you see is that the launchpad toolchain has C99 formats disabled. You may want to check out this toolchain compilation - https://sourceforge.net/projects/bleeding-edge/ (info here http://www.freddiechopin.info/en/articles/35-arm/87-bleeding-edge-toolchain-o-co-chodzi ). It has - among others - C99 formats enabled. I'm doing these compilations and I've been using them for over 2 years with no issues.

Regards,
FCh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]