size idx( 0 );
char string[ 256 ] = "";
sprintf( string, "%lu", idx );
with cppcheck v1.90 results in:
(cppcheck portability) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'size_t {aka unsigned long}'.
where is the mistake?
Best regards,
Christoph
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah, ok, I was a little confused by requires 'unsigned long' but..... 'aka unsigned long'...
Thank you very much!
In my case, it's %Iu (capital i instead of l).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
size idx( 0 );
char string[ 256 ] = "";
sprintf( string, "%lu", idx );
with cppcheck v1.90 results in:
(cppcheck portability) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'size_t {aka unsigned long}'.
where is the mistake?
Best regards,
Christoph
it's by intention.. your code is not portable. Use a format string that requires 'size_t'.
Not sure but I think
%zu
might be better.Ah, ok, I was a little confused by requires 'unsigned long' but..... 'aka unsigned long'...
Thank you very much!
In my case, it's %Iu (capital i instead of l).