How to represent void pointer function into Android JNI?Typedef function pointer?issue creating java native interfaceJNI pass parameters to method of c++How to use a jobject array ? (Jni)Unsatisfied Link ErrorAndroid JNI UnsatisfiedLink ExceptionJNI: How to convert a group of data from c++ to Javajni undefined symbol errorAndroid-Android OpenCV after perspectiveWarp/warpPerspective getting blank(Black) image as a result?change Byte[] values in JNI with android studio

Infinitely many primes

Is storing sensitive data in files instead of a database safe?

O.5=north.5 (are this the same?)

Is future tense in English really a myth?

How to best explain that you are taking pictures in a space for practice reasons?

Can taking my 1-week-old on a 6-7 hours journey in the car lead to medical complications?

How strong is aircraft-grade spruce?

"syntax error near unexpected token" after editing .bashrc

Poor management handling of recent sickness and how to approach my return?

How do I make my fill-in-the-blank exercise more obvious?

Relationship between speed and cadence?

Entering the US with dual citizenship but US passport is long expired?

Why did Boris Johnson call for new elections?

How do I write a vertically-stacked definition of a sequence?

Fantasy Military Arms and Armor: the Dwarven Grand Armory

Filling attribute tables with values from the same attribute table

What quests do you need to stop at before you make an enemy of a faction for each faction?

When does order matter in probability?

Friend is very nit picky about side comments I don't intend to be taken too seriously

Contractor cut joist hangers to make them fit

Is mountain bike good for long distances?

Examples where "thin + thin = nice and thick"

Laptop failure due to constant fluctuation of AC frequency and voltage

What is the extent of the commands a Cambion can issue through Fiendish Charm?



How to represent void pointer function into Android JNI?


Typedef function pointer?issue creating java native interfaceJNI pass parameters to method of c++How to use a jobject array ? (Jni)Unsatisfied Link ErrorAndroid JNI UnsatisfiedLink ExceptionJNI: How to convert a group of data from c++ to Javajni undefined symbol errorAndroid-Android OpenCV after perspectiveWarp/warpPerspective getting blank(Black) image as a result?change Byte[] values in JNI with android studio






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I don't know how to map it correctly.



C method



void* function(char* h, int p, void (*vrecv)(void* , uint8_t *, size_t ), 
void* d, const char* n, uint8_t p8, uint16_t p16, uint32_t p32);


JNI wrapper method



JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_function( JNIEnv* env, jobject thiz,
blah-blah )
return blah-blah;



Java method



public native void function();







There are few examples with
access through an java array, calling with method CallVoidMethod or with GetMethodId, but I don't understand them. It's hard to see the idea through java method, c/c++ func and jni wrapped method.



Tutorial for JNI API



Google Android NDK / JNI Samples





This is example works fine:



HelloJni.java file.



JNIEXPORT jint JNICALL Java_com_example_hellojni_HelloJni_example(JNIEnv*env,
jobject obj)
return (jint) example();



hello-jni.c file.



void* run_thread(void* num) 
int* temp = (int*) num;

while(++(*temp) < 777);

printf("Hello world! C Style! From pthread and Android NDK(JNI).n");

return NULL;


int example()
int f = 0;
pthread_t pipe;

if(pthread_create(&pipe, NULL, run_thread, &x))
fprintf(stderr, "Error creating threadn");
return 1;


sleep(1);

printf("before x: %dn", x);

/* wait for the second thread to finish */
if(pthread_join(pipe, NULL))
fprintf(stderr, "Error joining threadn");
return 2;


printf("after x: %dn", x);

return x;



How to access c data structures?



public native void example1(/**/);




How to call elements of typedef struct?



What next step for void* pointer (a correct representation with long cause 64 bit)?



public native void example2(long cl);
public native void example3(/**/);
public native void example4(/**/);





void* example1(char* h, int p, void (*vr)(void* , uint8_t *, size_t ), void* vdt,
void (*ar)(void* , uint8_t *, size_t ), void* adt);
void example2(void* cl);
void example3(void* cl, uint8_t is_p, uint8_t num, const char* name, uint8_t btype, uint8_t v, uint8_t prod, uint16_t opts);
void example4(void* cl, uint8_t num, uint16_t t, uint32_t c, uint32_t v);





JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example1 (JNIEnv* env, jobject obj, jchar* h, jint p, jlong vr, jlong vdt, jlong ar, jlong adt) 
const char *str= (*env)->GetStringUTFChars(env,h,0);

example1(str, p, vr, vdt, ar, adt);

JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example2 (JNIEnv* env, jobject obj, jlong cl)
example2(cl);

JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example3 (JNIEnv* env, jobject obj, jlong cl, uint8_t is_p, uint8_t num,
jstring name, uint8_t btype, uint8_t v, uint8_t prod, uint16_t opts)

const char *str= (*env)->GetStringUTFChars(env,name,0);

example3(cl, (jshort)is_p, num, str, (jshort)btype, (jshort)v, (jshort)prod, (jshort)opts);

JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example4 (JNIEnv* env, jobject obj, jlong cl, uint8_t num, uint16_t t, uint32_t c, uint32_t v)
example4(cl, (jshort)num, (jshort) t, (jlong)(unsigned long long) c, (jlong)(unsigned long long) v);










share|improve this question
































    0















    I don't know how to map it correctly.



    C method



    void* function(char* h, int p, void (*vrecv)(void* , uint8_t *, size_t ), 
    void* d, const char* n, uint8_t p8, uint16_t p16, uint32_t p32);


    JNI wrapper method



    JNIEXPORT jstring JNICALL
    Java_com_example_hellojni_HelloJni_function( JNIEnv* env, jobject thiz,
    blah-blah )
    return blah-blah;



    Java method



    public native void function();







    There are few examples with
    access through an java array, calling with method CallVoidMethod or with GetMethodId, but I don't understand them. It's hard to see the idea through java method, c/c++ func and jni wrapped method.



    Tutorial for JNI API



    Google Android NDK / JNI Samples





    This is example works fine:



    HelloJni.java file.



    JNIEXPORT jint JNICALL Java_com_example_hellojni_HelloJni_example(JNIEnv*env,
    jobject obj)
    return (jint) example();



    hello-jni.c file.



    void* run_thread(void* num) 
    int* temp = (int*) num;

    while(++(*temp) < 777);

    printf("Hello world! C Style! From pthread and Android NDK(JNI).n");

    return NULL;


    int example()
    int f = 0;
    pthread_t pipe;

    if(pthread_create(&pipe, NULL, run_thread, &x))
    fprintf(stderr, "Error creating threadn");
    return 1;


    sleep(1);

    printf("before x: %dn", x);

    /* wait for the second thread to finish */
    if(pthread_join(pipe, NULL))
    fprintf(stderr, "Error joining threadn");
    return 2;


    printf("after x: %dn", x);

    return x;



    How to access c data structures?



    public native void example1(/**/);




    How to call elements of typedef struct?



    What next step for void* pointer (a correct representation with long cause 64 bit)?



    public native void example2(long cl);
    public native void example3(/**/);
    public native void example4(/**/);





    void* example1(char* h, int p, void (*vr)(void* , uint8_t *, size_t ), void* vdt,
    void (*ar)(void* , uint8_t *, size_t ), void* adt);
    void example2(void* cl);
    void example3(void* cl, uint8_t is_p, uint8_t num, const char* name, uint8_t btype, uint8_t v, uint8_t prod, uint16_t opts);
    void example4(void* cl, uint8_t num, uint16_t t, uint32_t c, uint32_t v);





    JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example1 (JNIEnv* env, jobject obj, jchar* h, jint p, jlong vr, jlong vdt, jlong ar, jlong adt) 
    const char *str= (*env)->GetStringUTFChars(env,h,0);

    example1(str, p, vr, vdt, ar, adt);

    JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example2 (JNIEnv* env, jobject obj, jlong cl)
    example2(cl);

    JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example3 (JNIEnv* env, jobject obj, jlong cl, uint8_t is_p, uint8_t num,
    jstring name, uint8_t btype, uint8_t v, uint8_t prod, uint16_t opts)

    const char *str= (*env)->GetStringUTFChars(env,name,0);

    example3(cl, (jshort)is_p, num, str, (jshort)btype, (jshort)v, (jshort)prod, (jshort)opts);

    JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example4 (JNIEnv* env, jobject obj, jlong cl, uint8_t num, uint16_t t, uint32_t c, uint32_t v)
    example4(cl, (jshort)num, (jshort) t, (jlong)(unsigned long long) c, (jlong)(unsigned long long) v);










    share|improve this question




























      0












      0








      0








      I don't know how to map it correctly.



      C method



      void* function(char* h, int p, void (*vrecv)(void* , uint8_t *, size_t ), 
      void* d, const char* n, uint8_t p8, uint16_t p16, uint32_t p32);


      JNI wrapper method



      JNIEXPORT jstring JNICALL
      Java_com_example_hellojni_HelloJni_function( JNIEnv* env, jobject thiz,
      blah-blah )
      return blah-blah;



      Java method



      public native void function();







      There are few examples with
      access through an java array, calling with method CallVoidMethod or with GetMethodId, but I don't understand them. It's hard to see the idea through java method, c/c++ func and jni wrapped method.



      Tutorial for JNI API



      Google Android NDK / JNI Samples





      This is example works fine:



      HelloJni.java file.



      JNIEXPORT jint JNICALL Java_com_example_hellojni_HelloJni_example(JNIEnv*env,
      jobject obj)
      return (jint) example();



      hello-jni.c file.



      void* run_thread(void* num) 
      int* temp = (int*) num;

      while(++(*temp) < 777);

      printf("Hello world! C Style! From pthread and Android NDK(JNI).n");

      return NULL;


      int example()
      int f = 0;
      pthread_t pipe;

      if(pthread_create(&pipe, NULL, run_thread, &x))
      fprintf(stderr, "Error creating threadn");
      return 1;


      sleep(1);

      printf("before x: %dn", x);

      /* wait for the second thread to finish */
      if(pthread_join(pipe, NULL))
      fprintf(stderr, "Error joining threadn");
      return 2;


      printf("after x: %dn", x);

      return x;



      How to access c data structures?



      public native void example1(/**/);




      How to call elements of typedef struct?



      What next step for void* pointer (a correct representation with long cause 64 bit)?



      public native void example2(long cl);
      public native void example3(/**/);
      public native void example4(/**/);





      void* example1(char* h, int p, void (*vr)(void* , uint8_t *, size_t ), void* vdt,
      void (*ar)(void* , uint8_t *, size_t ), void* adt);
      void example2(void* cl);
      void example3(void* cl, uint8_t is_p, uint8_t num, const char* name, uint8_t btype, uint8_t v, uint8_t prod, uint16_t opts);
      void example4(void* cl, uint8_t num, uint16_t t, uint32_t c, uint32_t v);





      JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example1 (JNIEnv* env, jobject obj, jchar* h, jint p, jlong vr, jlong vdt, jlong ar, jlong adt) 
      const char *str= (*env)->GetStringUTFChars(env,h,0);

      example1(str, p, vr, vdt, ar, adt);

      JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example2 (JNIEnv* env, jobject obj, jlong cl)
      example2(cl);

      JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example3 (JNIEnv* env, jobject obj, jlong cl, uint8_t is_p, uint8_t num,
      jstring name, uint8_t btype, uint8_t v, uint8_t prod, uint16_t opts)

      const char *str= (*env)->GetStringUTFChars(env,name,0);

      example3(cl, (jshort)is_p, num, str, (jshort)btype, (jshort)v, (jshort)prod, (jshort)opts);

      JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example4 (JNIEnv* env, jobject obj, jlong cl, uint8_t num, uint16_t t, uint32_t c, uint32_t v)
      example4(cl, (jshort)num, (jshort) t, (jlong)(unsigned long long) c, (jlong)(unsigned long long) v);










      share|improve this question
















      I don't know how to map it correctly.



      C method



      void* function(char* h, int p, void (*vrecv)(void* , uint8_t *, size_t ), 
      void* d, const char* n, uint8_t p8, uint16_t p16, uint32_t p32);


      JNI wrapper method



      JNIEXPORT jstring JNICALL
      Java_com_example_hellojni_HelloJni_function( JNIEnv* env, jobject thiz,
      blah-blah )
      return blah-blah;



      Java method



      public native void function();







      There are few examples with
      access through an java array, calling with method CallVoidMethod or with GetMethodId, but I don't understand them. It's hard to see the idea through java method, c/c++ func and jni wrapped method.



      Tutorial for JNI API



      Google Android NDK / JNI Samples





      This is example works fine:



      HelloJni.java file.



      JNIEXPORT jint JNICALL Java_com_example_hellojni_HelloJni_example(JNIEnv*env,
      jobject obj)
      return (jint) example();



      hello-jni.c file.



      void* run_thread(void* num) 
      int* temp = (int*) num;

      while(++(*temp) < 777);

      printf("Hello world! C Style! From pthread and Android NDK(JNI).n");

      return NULL;


      int example()
      int f = 0;
      pthread_t pipe;

      if(pthread_create(&pipe, NULL, run_thread, &x))
      fprintf(stderr, "Error creating threadn");
      return 1;


      sleep(1);

      printf("before x: %dn", x);

      /* wait for the second thread to finish */
      if(pthread_join(pipe, NULL))
      fprintf(stderr, "Error joining threadn");
      return 2;


      printf("after x: %dn", x);

      return x;



      How to access c data structures?



      public native void example1(/**/);




      How to call elements of typedef struct?



      What next step for void* pointer (a correct representation with long cause 64 bit)?



      public native void example2(long cl);
      public native void example3(/**/);
      public native void example4(/**/);





      void* example1(char* h, int p, void (*vr)(void* , uint8_t *, size_t ), void* vdt,
      void (*ar)(void* , uint8_t *, size_t ), void* adt);
      void example2(void* cl);
      void example3(void* cl, uint8_t is_p, uint8_t num, const char* name, uint8_t btype, uint8_t v, uint8_t prod, uint16_t opts);
      void example4(void* cl, uint8_t num, uint16_t t, uint32_t c, uint32_t v);





      JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example1 (JNIEnv* env, jobject obj, jchar* h, jint p, jlong vr, jlong vdt, jlong ar, jlong adt) 
      const char *str= (*env)->GetStringUTFChars(env,h,0);

      example1(str, p, vr, vdt, ar, adt);

      JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example2 (JNIEnv* env, jobject obj, jlong cl)
      example2(cl);

      JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example3 (JNIEnv* env, jobject obj, jlong cl, uint8_t is_p, uint8_t num,
      jstring name, uint8_t btype, uint8_t v, uint8_t prod, uint16_t opts)

      const char *str= (*env)->GetStringUTFChars(env,name,0);

      example3(cl, (jshort)is_p, num, str, (jshort)btype, (jshort)v, (jshort)prod, (jshort)opts);

      JNIEXPORT void JNICALL Java_com_example_hellojni_HelloJni_example4 (JNIEnv* env, jobject obj, jlong cl, uint8_t num, uint16_t t, uint32_t c, uint32_t v)
      example4(cl, (jshort)num, (jshort) t, (jlong)(unsigned long long) c, (jlong)(unsigned long long) v);







      java-native-interface typedef void-pointers






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 4 at 9:56







      Bulat

















      asked Mar 28 at 6:04









      BulatBulat

      7587 silver badges15 bronze badges




      7587 silver badges15 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391083%2fhow-to-represent-void-pointer-function-into-android-jni%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391083%2fhow-to-represent-void-pointer-function-into-android-jni%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript