-1

everyone. I am writing under Android using JNI. I need to pass an "interval" into my C foo() as uint16, but after that i use the same "interval" in return to Java.

C:

 static jint func (JNIEnv* env, jobject object,jstring first)
        {
        /*...action...*/
        uint16  interval;
        jint result = foo (ifirst, &interval);
        return result < 0 ? result : interval;
        }

I have error below

error: operands to ?: have different types 'jint {aka int}' and 'uint16* {aka short unsigned int*}'

how can i use 'interval' argument to avoid an error and continue correct work of program?

Ahmet Kakıcı
  • 6,294
  • 4
  • 37
  • 49
user3360601
  • 327
  • 3
  • 17
  • 1
    Is this the code that you actually have? The error message doesn't match: it says that the operands are an int and a *pointer* to `uint16`. – Joni Feb 27 '14 at 13:25
  • you are write, after getting an error, i removed the pointer and forgot about it. i'm sorry. – user3360601 Feb 27 '14 at 13:52

1 Answers1

1

Based on the code, you need to add a cast to ensure that both conditions of the ?: operator are the same type.

 static jint func (JNIEnv* env, jobject object,jstring first)
 {
    /*...action...*/
    uint16  interval;
    jint result = foo (ifirst, &interval);
    return result < 0 ? result : (jint)interval;
 }
Samhain
  • 1,767
  • 1
  • 12
  • 20