Skip to content

Commit

Permalink
fix: Fix sprintf warning on 32bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Berstanio committed Jul 7, 2024
1 parent 23c788d commit 209d941
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdint.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdexcept>
Expand Down Expand Up @@ -125,7 +126,7 @@ void get_native_type(native_type* nat_type) {
int _size##argument_index = sizeof(type); \
if (!CHECK_BOUNDS_FOR_NUMBER(value, _size##argument_index, _signed##argument_index)) { \
char buffer[1024]; \
snprintf(buffer, sizeof(buffer), "Value %ld is out of bound for size %d and signess %d on argument %d", (jlong)value, _size##argument_index, _signed##argument_index, argument_index); \
snprintf(buffer, sizeof(buffer), "Value %" PRId64 " is out of bound for size %d and signess %d on argument %d", (jlong)value, _size##argument_index, _signed##argument_index, argument_index); \
env->ThrowNew(illegalArgumentExceptionClass, buffer); \
returnAction; \
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class JniGenTestClass {

/*JNI
#include <stdio.h>
#include <inttypes.h>
*/

public static native boolean testBoolean(boolean boolArg); /*
Expand Down Expand Up @@ -49,7 +50,7 @@ public static native boolean test (boolean boolArg, byte byteArg, char charArg,
printf("char: %c\n", charArg);
printf("short: %d\n" , shortArg);
printf("int: %d\n", intArg);
printf("long: %ld\n", longArg);
printf("long: %" PRId64 "\n", longArg);
printf("float: %f\n", floatArg);
printf("double: %f\n", doubleArg);
printf("byteBuffer: %d\n", byteBuffer [0]);
Expand Down

0 comments on commit 209d941

Please sign in to comment.