Skip to content

Instantly share code, notes, and snippets.

@mkropat
Created September 12, 2021 21:56
Show Gist options
  • Save mkropat/c9de282788c8dc23ed0c0d4fb8c9f698 to your computer and use it in GitHub Desktop.
Save mkropat/c9de282788c8dc23ed0c0d4fb8c9f698 to your computer and use it in GitHub Desktop.
// gcc -I$JAVA_HOME/include -I$JAVA_HOME/include/linux jsizes.c -o jsizes && ./jsizes
#include <stdio.h>
#include <jni.h>
int main() {
printf("jboolean %li\n", sizeof (jboolean));
printf("jbyte %li\n", sizeof (jbyte));
printf("jchar %li\n", sizeof (jchar));
printf("jshort %li\n", sizeof (jshort));
printf("jint %li\n", sizeof (jint));
printf("jlong %li\n", sizeof (jlong));
printf("jfloat %li\n", sizeof (jfloat));
printf("jdouble %li\n", sizeof (jdouble));
printf("jsize %li\n", sizeof (jsize));
printf("\n");
printf("unsigned char %li\n", sizeof(unsigned char));
printf("unsigned short %li\n", sizeof(unsigned short));
printf("unsigned int %li\n", sizeof(unsigned int));
printf("unsigned long %li\n", sizeof(unsigned long));
printf("unsigned long long %li\n", sizeof(unsigned long long));
return 0;
}
#include <stdio.h>
int main() {
printf("int %li\n", sizeof (int));
printf("long %li\n", sizeof (long));
printf("size_t %li\n", sizeof (size_t));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment