Hi DevZone,
We are trying to move our existing application from SEGGER compilation to a GCC build for CI / CD purposes. However we are seeing a strange bug with uint64_t types and our cJSON library.
We can compile the following snippet in both applications, however, only the SEGGER build succesfully prints out the formatted cJSON string:
cJSON *json_object = cJSON_CreateObject();
/* Timestamp and ID are the same for all measurement types */
uint64_t integer_64 = (((uint64_t)1) << 63);
uint32_t integer_32 = 684956;
cJSON_AddNumberToObject(json_object, "integer64", integer_64);
cJSON_AddNumberToObject(json_object, "integer32", integer_32);
char* json_string = cJSON_PrintUnformatted(json_object);
if (!json_string) {
NRF_LOG_ERROR("Could not create string");
}
NRF_LOG_INFO("%llu: %s", integer_64, json_string);
Which outputs:
GCC Output:
<info> main: 0: {"integer64":,"integer32":684956}
SEGGER Output:
<info> main: 0: {"integer64":9223372036854776000,"integer32":684956}
I tried printing out NRF_LOG_INFO("Newlib: %s", _NEWLIB_VERSION); and it seems that SEGGER is using a different libc implementation as __NEWLIB_VERSION is only defined in the GCC build, so this must be a clue in what's going wrong. I don't know why newlib wouldn't work with the above code.
Any help in figuring out how to get this working under GCC? Thank you for the help.
Best regards,
Mattia