LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Conflicting type declarations between sys/types.h and linux/types.h (http://www.linuxquestions.org/questions/programming-9/conflicting-type-declarations-between-sys-types-h-and-linux-types-h-831809/)

Da Shi Cao 09-13-2010 12:14 AM

Conflicting type declarations between sys/types.h and linux/types.h
 
I'm trying to use "netlink" to get ip address of a Linux box. But the linux/types.h included from "linux/rtnetlink.h" introduced many conflicting type declarations with "sys/types.h".

#include <rtnetlink.h>
#include <sys/types.h>
#include <sys/socket.h>

int main (int argc, char *argv[])
{
return 0;
}

The program will demonstrate such type conflicts.

14moose 09-13-2010 12:27 AM

Q: is your code meant to be a kernel module, or a user-space application?

Q: does this compile?
Code:

#include <sys/types.h>
#include <sys/socket.h>
#include <linux/rtnetlink.h>

int main (int argc, char *argv[])
{
  return 0;
}

PS:
It does compile for me. I'm just not sure whether or not it's the "correct" solution for your problem.

Da Shi Cao 09-13-2010 04:36 AM

A user space application is desired.
The "rtnetlink.h" should be written as "linux/rtnetlink.h".
There is only one copy of "rtnetlink.h", namely "linux/rtnetlink.h".
I'm not sure if there is a header file that should be used for a user space program.
But a "find" in /usr/include reveals that only one "rtnetlink.h" exists on my system.

Da Shi Cao 09-14-2010 12:55 AM

It seems that changing the order of including of the headers does eliminates the complains of gcc about the conflicting type declarations. I'm also not sure if this is the solution. It is a workaround at least.

Thanks.

Dashi Cao


All times are GMT -5. The time now is 03:10 PM.