简体   繁体   中英

Android: JNI function pointer initialization from incompatible pointer type

I have this code:

FLAC__StreamDecoderWriteStatus writeCallback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) {
   //impl....
}

and then later on I have this declaration:

{    
/// stuff
FLAC__StreamDecoderWriteStatus (*writeCallbackPtr) (const FLAC__StreamEncoder *, const FLAC__byte  , size_t , unsigned , unsigned , void *) = writeCallback;
// more stuff
}   

My understanding of the error is that the two are of different types, but I don't understand what I'm doing wrong in this case.

Your declaration is wrong, it should be

FLAC__StreamDecoderWriteStatus (*writeCallbackPtr) (
    const FLAC__StreamEncoder *, 
    const FLAC__byte[], 
    /*         here ^ you missed the [] */         
    size_t , 
    unsigned , 
    unsigned , 
    void *) = writeCallback;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM