Wrong result when printing a int64_t value using STM32CubeIDE
I trying to use sprintf to display some values for debug purposes. I am getting wrong results in STM32CubeIDE v1.5.0 but it is working with an online gcc compiler.
The code is in a function and for now I'm re-assigning the values inside the function for debug. Here is my code in STM32CubeIDE:
void log_data(int16_t u, int16_t y, int64_t z, int16_t indx )
{
u = 50;
y= 100;
z= 4351234;
indx= 0;
static char msg[48];
sprintf(msg, "%d %d %lld %d \r\n>", u, y, z, indx);
HAL_UART_Transmit_IT(&huart3, (uint8_t *) msg, strlen(msg)); // &huart3 &hlpuart1
}The result displays:
50 100 ld 4351234
>
In the online gcc compiler I run this program:
// Online C compiler to run C program online
#include <stdio.h>
#define int16_t __int16_t
#define int64_t __int64_t
int main() {
// Write C code here
int16_t u = 50;
int16_t y = 100;
int64_t z = 4351234;
int16_t indx = 0;
static char msg[48];
sprintf(msg, "%d %d %lld %d \r\n>", u, y, z, indx);
printf("Hello world %s" , msg);
return 0;
}The display is: Hello world 50 100 4351234 0
All is as I expect it to be.
Note the STM32CubeIDE code displays characters 'ld' in the 3rd position of the output and the last value (indx) which should be 0 is not displays.
If I change z to 9876543210 the online compiler gives the correct result but STMCubeIDE prints the following: 50 100 ld 1286608618
What can I do to print a 64-bit int value?
Thanks,
Brian

