This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

thingy91:nRF52840 int64_t convert the value to string in sprintf

thingy91:nRF52840 int64_t convert the value to string in sprintf

Add next line in proj.conf

CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_NANO=n

If you do the following:

int64_t xxx = 1609665300;
int8_t unix_time[256] = {'\0'};

sprintf(unix_time, "%"PRIu64" ", xxx);
printk("unix_time = %s\n",unix_time);
sprintf(unix_time, "%llu", xxx);
printk("unix_time = %s\n",unix_time);
sprintf(unix_time, "%lld", xxx);
printk("unix_time = %s\n",unix_time);

As a result

unix_time = lu
unix_time = lu
unix_time = ld

Is there a CONFIG that is not enough?

Related