snprintf compatibility issue between Cross ARM gcc and g++ x64 compiler
Hello,
I'm trying to compile my ARM CM4F firmware to x64 architecture with Cygwin g++. I'm doing this to set up a test environment. I'm having the following issue to port sprintf function:
In my arm firmware I want to use:
char myBuffer[20];
uint32_t myVar = 1234;
uint16_t size;
size = sprintf(myBuffer, "%lu", myVar);
This code compiles with Cross ARM gcc.
When compiling the same code with Cygwin g++, I get the following error:
format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'uint32_t {aka unsigned int}' [-Werror=format=]
I'd like to know if there's any way to port sprintf such way that it compiles for both architectures. Otherwise I will need to adapt my code for when I'm running tests and when I'm compiling my production code, which is not interesting.
Best Regards,
Denis
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Thomas Preud'homme
- Solved:
- Last query:
- Last reply: