Hello,
I would like to print signed long long int (s64_t ) values using printk or printf.
I tried some suggestions I found online %lli , %lld but they did not work.
Please advise.
Thank you.
Kind regards
Mohamed
Hello,
I would like to print signed long long int (s64_t ) values using printk or printf.
I tried some suggestions I found online %lli , %lld but they did not work.
Please advise.
Thank you.
Kind regards
Mohamed
Hi,
With ncs v1.5.0-rc1 (with minimal lib c), it should print 64 bit numbers using printk(). I added this to the hello_world sample:
int64_t long_num = 0x10000000000; printk("%lli\n", long_num);
And it prints:
Hello World! nrf9160dk_nrf9160 1099511627776
Which tag are you on?
Kind regards,
Håkon
Thank you Hakon,
Yes, it works with int64_t type but for some reason it did not work with s64_t type which is what I was using when I posted my ticket.
Kind regards
Mohamed
Which tag are you on?
I am not sure which tag you are referring to.
Hi Mohamed,
Learner said:I am not sure which tag you are referring to.
The ncs version you're using. I tested this on v1.5.0-rc1. You should be on tag v1.4.99-dev1 or newer when developing with the nRF5340 revision 1 (the production silicon), as there's additions to the startup files that were added in this tag.
If you open a command line or git bash, and go into the path/to/ncs/nrf, then write "git branch", it should show you which version of ncs you're currently building from.
Here's my output:
$ git branch * (HEAD detached at v1.5.0-rc1)
Learner said:Yes, it works with int64_t type but for some reason it did not work with s64_t type which is what I was using when I posted my ticket.
those are variations of the same type. If one of them works, the other should as well. could you add details about your project? Do you use printf or printk?
It can be problematic to print 64 bit using printf(), especially if you are using "CONFIG_NEWLIB_LIBC_NANO=y" in your project.
Can you share your project?
Kind regards,
Håkon
Hi Hakon,
I am using v1.5-rc1
C:\Zypher\v1.5.0-rc1\nrf>git branch
* (HEAD detached at v1.5.0-rc1)
I am also using this in my prj.conf file
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_PRINTK=y
What does the config line CONFIG_NEWLIB_LIBC_NANO=y do?
I agree s64_t and int64_t are the same type but printf does not like neither types. However, printk is now happy with both int64_t and s64_t. It is bizarre, I thought at first printk also did not like s64_t.
Anyway, I can now print both s64_t and int64_t using printk but not printf.
Kind regards
Mohamed