Page 1 of 1

support with %ULL

Posted: Wed Feb 21, 2018 6:04 am
by david_h
Before I get too far I wanted to layout some basics we are using nbeclipse on a windows7 machine with the mod54417.
Recently when working with a character stream on the mod54417 I realized that the conversion from the 64 character string to a standard layout seems to be packing erroneous values. In most cases it appears to shift the value left 32. If the full string isn't predefined and zeroed it was shifting the stream and packing a value in to it.
basic code call:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
Main(){
...
char value[64];
memset(value,0,64);
strcpy(value, "01234");
uint64_t i;
int m=sscanf(value, "%llu", &i);
iprintf("%x \r\n",m);
iprintf("%" PRIx64 " \r\n",i);
...
}
Output:
1
4d200000000

when stepping into the libraries I noticed that in newlib.h the below are laid out:
/* C99 formats support (such as %a, %zu, ...) in IO functions like
* printf/scanf enabled */
/* #undef _WANT_IO_C99_FORMATS */

/* long long type support in IO functions like printf/scanf enabled */
/* #undef _WANT_IO_LONG_LONG */
We also started to look at using strtoumax instead of the above layout and it seems that you were externing it but when calling the function it wasn't linking to our application. I am hoping the issue is something basic in my code.

Re: support with %ULL

Posted: Thu Feb 22, 2018 2:37 pm
by pbreed
%llu is supported for printf, but not presently for scanf.
We'll take a look at turning it on..

Re: support with %ULL

Posted: Thu Feb 22, 2018 5:09 pm
by pbreed
This works:

#include <stdlib.h>

unsigned long long llu;
const char * txt="12345678901234";
llu=strtoull(txt,&pend,10);
iprintf("strull =%llu\r\n",llu);

Yields :
strull =12345678901234

So strtoull works....
I've tested this under 2.8.5 and 2.8.6

Re: support with %ULL

Posted: Fri Feb 23, 2018 10:29 am
by david_h
thanks that should work for what we need.