簡體   English   中英

如何將以下參考變量轉換為Java JNA?

[英]How can I convert the following reference variable into Java JNA?

我在C中有以下語法方法。

ipj_error ipj_get_value(
ipj_iri_device* iri_device,     /**< [in] IRI device data structure */
ipj_key key,                    /**< [in] Key code to get */
uint32_t* value)                /**< [out] Data buffer to store retrieved value */
{
    return ipj_get(iri_device, key, 0, 0, value);
}

在這種方法中,參考價值。 我如何在JNA中定義它? 我嘗試聲明為int,但這沒有任何意義。 因為在C中,如果我將其聲明為int,則C值會返回某些內容,這意味着im會將整數值傳遞給該方法。 那么,如何聲明此ipj_get_value以及如何聲明該值? 請指教。

我也嘗試了IntByReference。 但是,當我嘗試使用getValue()獲取值時,它始終返回0。

JNA提供IntByReference來通過引用傳遞32位值。

int passedValue = ...;
IntByReference iref = new IntByReference(passedValue);
lib.invokeMyMethod(iref);
int returnedValue = iref.getValue();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM