编写android应用程序去操作i2c函数,nkd-build出错: error: dereferencing pointer to incomplete type
以下是我的.c文件
1#include <jni.h>
2 #include <stdio.h>
3 #include <string.h>
5 #include <android/log.h>
6 #include <linux/i2c.h>
7 #include <malloc.h>
8 #include <memory.h>
9 #include <fcntl.h>
10 #include <linux/delay.h>
12 //#include <sys/ioctl.h>
13
14 #define LOG_TAG "i2c"
15 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__ )
16 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS_ _)
17
18 //-------------------
19 extern struct i2c_client *infer_ldtp_i2c_client;
20
21 JNIEXPORT jint JNICALL Java_com_example_ips_1tp_1update_IPS_1tp_1updateActiv ity_open(JNIEnv *env, jobject obj, jstring file)
22 {
23 LOGI("begin to open");
24 char fileName[64];
25 const jbyte *str;
26
27 str = (*env)->GetStringUTFChars(env, file, NULL);
28 if (str == NULL) {
29 LOGI("Can't get file name!");
30 return -1;
31 }
32 sprintf(fileName, "%s", str);
33 LOGI("will open i2c device node %s", fileName);
34 (*env)->ReleaseStringUTFChars(env, file, str);
35 LOGI("out open");
36 //-------------------
37 struct i2c_client *client = infer_ldtp_i2c_client;
38 int ret;
39 struct i2c_msg msgs[] = {
40 {
41 .addr = client->addr, ------------------>这里出错
42 .flags = 0,
43 .len = 1,
44 // .buf = cmdbuf,
45 },