support with %ULL

Discussion to talk about hardware related topics only.
Post Reply
david_h
Posts: 2
Joined: Tue Feb 20, 2018 12:26 pm

support with %ULL

Post 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.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: support with %ULL

Post by pbreed »

%llu is supported for printf, but not presently for scanf.
We'll take a look at turning it on..
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: support with %ULL

Post 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
david_h
Posts: 2
Joined: Tue Feb 20, 2018 12:26 pm

Re: support with %ULL

Post by david_h »

thanks that should work for what we need.
Post Reply