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
Which tag are you on?
I am not sure which tag you are referring to.
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
Hi Mohamed,
printf() is supplied with the libc (which supplies standard functions, like printf()/scan() etc, and headers) that you use, which is newlibc in your case. This is supplied with the compiler suite, and not with zephyr.
If you choose to use minimal libc instead, this is supplied with zephyr, and does support 64-bit printf() operations. By removing the CONFIG_NEWLIB* configurations from your prj.conf, it will select the "MINIMAL_LIBC" instead.
Could you try the minimal libc instead and see if that works better?
Kind regards,
Håkon
Good morning Hakon,
Correct me if I am wrong but I think printk() does not handle float well and this is the reason I included
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
Kind regards
Mohamed
Good morning Mohamed,
If you use newlib c, those needs to be set in order to use printf() with floats. printk needs "CONFIG_CBPRINTF_FP_SUPPORT" for float.
In the case of minimal libc, you should include "CONFIG_MINIMAL_LIBC_LL_PRINTF" to allow 64 bit printing.
Kind regards,
Håkon
Hi Hakon,
I am getting rather confused with what lib to use for what purpose .
I need to be able to print all types of values including float, intx_t int64_t etc... So, which lib should I be including?
Thank you.
Kind regards
Mohamed
Hi Hakon,
I am getting rather confused with what lib to use for what purpose .
I need to be able to print all types of values including float, intx_t int64_t etc... So, which lib should I be including?
Thank you.
Kind regards
Mohamed
Hi,
Learner said:I need to be able to print all types of values including float, intx_t int64_t etc... So, which lib should I be including?
I would recommend that you setup a project that prints the types you want to print, via printk() and/or printf(), then set your local project configuration wrt. each standard libc, and see which one fits your needs.
Kind regards,
Håkon
Thank you Hakon.