2025-12-02 10:10 AM
I'm running into a strange issue: the following function compiles cleanly on one machine but triggers a compiler error on another. Both machines are running the same version of STM32CubeIDE (2.0.0), and the project is shared via a Git repo on Azure DevOps.
Here is the function in question:
#ifdef __cplusplus
extern "C" {
#endif
#include "aws_iot_json_utils.h"
#include <stdio.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <stm32l4xx.h>
IoT_Error_t parseUnsignedInteger8Value(uint8_t *i, const char *jsonString, jsmntok_t *token) {
if(token->type != JSMN_PRIMITIVE) {
IOT_WARN("Token was not an integer");
return JSON_PARSE_ERROR;
}
if(('-' == (char) (jsonString[token->start])) || (1 != sscanf(jsonString + token->start, "%" SCNu8, i))) {
IOT_WARN("Token was not an unsigned integer.");
return JSON_PARSE_ERROR;
}
return SUCCESS;
}And here is the compiler error:
../Controller/mqtt/aws_iot_json_utils.c:84:101: error: expected ')' before 'SCNu8'
84 | if(('-' == (char) (jsonString[token->start])) || (1 != sscanf(jsonString + token->start, "%" SCNu8, i))) {
| ~ ^~~~~~
|
What am I missing?
I'm trying to understand why one machine accepts the SCNu8 macro from <inttypes.h> while the other rejects it, even though both environments should be identical. Any ideas on what could cause this discrepancy? Thanks.
2025-12-02 10:31 AM
> What am I missing?
a comma after "%" .
hth
KnarfB
2025-12-02 10:36 AM
If that's the case, it would fail on both machines.
I actually can fix the compile error by adding the preprocessor macro _WANT_IO_C99_FORMATS to this particular file. However, on the other machine, I don't have to, and that's the puzzle.
2025-12-02 10:46 AM
I see. Maybe this one helps: Solved: SCNu8 formatting - STMicroelectronics Community