我正在研究Beaglebone Black并在C中用IMU编写i2c的代码

当然会有很多read()和write()命令 . 但每次Eclipse输出错误“无效参数” .

int i2c_readbyte(int handle,char buff[],char regaddr){
   // Clear buffer
   memset(buff, 0, strlen(buff));

   buff[0]=regaddr;

   // Write address to handle
   if(write(handle,buff,1)!=1)
   {
       printf("Error:Register not accessible!!\n");
       return(-1);
   }

   // Read byte from handle
   if(read(handle, buff, 1)!=1)
   {
       printf("Error:Content corrupt!!\n");
       return(-1);
   }

   return(1);
}

错误是:无效的参数'int write(int,const void *,?)

无效的参数'int read(int,void *,?)

无效的参数'void * memset(void *,int,?)

我在提供商设置>>“检查”CDT GCC内置编译器设置[共享]中看到了其他答案 .

我试着索引>>重建 . 没有得到改善 .

unistd.h包括在内 . 我尝试了确切的example,但它给出了同样的错误 . 我注意到的区别在于"buff"数据类型 . 但是大多数I2C comm C程序都使用char数组 .