Using WSL2, NCS 2, VSCode.
I tried to snprintf("%ull\n", (uint64_t)5) but I only see "ul" printed to the screen.
Here are the relevant prj.conf values
Using WSL2, NCS 2, VSCode.
I tried to snprintf("%ull\n", (uint64_t)5) but I only see "ul" printed to the screen.
Here are the relevant prj.conf values
Hi,
Due to low staffing this week, answers may take longer than normal.
Regards,
Sigurd Hellesvik
Ok thanks, please help when you can.
From snprintf documentation, this function prints to a string and not as an output.
Moreover, when you describe it as snprintf("%ull\n", (uint64_t)5), you have 1 argument, but the snprintf needs 3 inputs.
What do you want to use sprintf for?
Regards,
Sigurd Hellesvik
Hi, I was using the snippet of code as shorthand for what I was doing in principle.
Here is how the code works. I'm wrapping the snprintf in a convenience function to make it easier to call. I'm converting values to strings.
static const uint8_t BUF_SIZE = 64; static char BUF[BUF_SIZE]; template <typename T> const char *StrC(const char *fmt, T val) { int bufSize = snprintf(BUF, BUF_SIZE, fmt, val); return FormatTemplateBase::BUF; }
The point is that when I use the format string for uint64_t it doesn't work as described above, even when used outside of the wrapper.
Can you help?
Thanks.
Is this what you are looking for?
main.c:
#include <zephyr/kernel.h> #include <stdio.h> void main(void) { uint8_t test[20] = "test"; uint64_t num = 111111111111111; snprintf(test, 20, "%llu", num); printk("Hello World! %s\n", test); }
Board: nrf52840dk_nrf52840
nRF Connect SDK: v2.3.0
Regards,
Sigurd Hellesvik