error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]

Jump to solution
13,953 Views
santhosh2
Contributor IV

Hi,

I am getting this error, I dont know for what reason i am getting this error, works for when compiled for PC

doesnt work when compiled for i.mx8mmini

------------------------------------------Error------------------------------------------------------

error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
   .write=device_write,
          ^~~~~~~~~~~~
/home/santhosh/Desktop/IP_Camera/App_development/Driver/imx8mmini_gpio_platformdevice.c:280:10: note: (near initialization for 'Fops.write')
/home/santhosh/Desktop/IP_Camera/App_development/Driver/imx8mmini_gpio_platformdevice.c:283:19: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
   .unlocked_ioctl=gpio_ioctl

--------------------------------------------------------------------------------------------------------------

The code is for quick reference

-------------------------------------start-code--------------------------------------------------------

struct file_operations Fops =
{
      .owner            =    THIS_MODULE,
      .read            =    device_read,
      .write            =    device_write,
      .open            =    device_open,
      .release        =    device_release,
      .unlocked_ioctl    =    gpio_ioctl
};

static int device_open(struct inode *inode, struct file *file)
{
  return 0;
}
static int device_release(struct inode *inode, struct file *file)
{
  return 0;
}
static ssize_t device_read(struct file *file, char __user *buffer, size_t length, loff_t * offset)
{
    return 0;
}
//static ssize_t device_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos)
static ssize_t device_write(struct file *file, char __user *buffer, size_t length, loff_t * offset)
{
  return 0;
}

int gpio_ioctl(struct file *file, unsigned int ioctl_num, unsigned long ioctl_param)
{

    return 0;

}

------------------------------------------------end-Code-----------------------------------------------------------

How can i resolve this issue

Regards

Santhosh

0 Kudos
1 Solution
12,489 Views
santhosh2
Contributor IV

The Issue got resolved, Its the GCC revision issue

Added a library and Recompiled it worked

Reference Link:c - Why am I getting an initialization from incompatible pointer type warning? - Stack Overflow 

View solution in original post

0 Kudos
3 Replies
12,489 Views
igorpadykov
NXP Employee
NXP Employee

one can try to recompile from scratch image (including application) using documentation :

i.MX Software | NXP 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
12,490 Views
santhosh2
Contributor IV

The Issue got resolved, Its the GCC revision issue

Added a library and Recompiled it worked

Reference Link:c - Why am I getting an initialization from incompatible pointer type warning? - Stack Overflow 

0 Kudos
12,489 Views
turker
Contributor IV

It seems you have -Werror compiler flag enabled. See this link link.

0 Kudos