LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-12-2010, 11:14 PM   #1
Da Shi Cao
LQ Newbie
 
Registered: Sep 2010
Location: China, People's Republic
Distribution: Debian
Posts: 3

Rep: Reputation: 0
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.
 
Old 09-12-2010, 11:27 PM   #2
14moose
Member
 
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
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.

Last edited by 14moose; 09-13-2010 at 05:53 PM.
 
1 members found this post helpful.
Old 09-13-2010, 03:36 AM   #3
Da Shi Cao
LQ Newbie
 
Registered: Sep 2010
Location: China, People's Republic
Distribution: Debian
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
Old 09-13-2010, 11:55 PM   #4
Da Shi Cao
LQ Newbie
 
Registered: Sep 2010
Location: China, People's Republic
Distribution: Debian
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getting "parameter has incomplete type" and "conflicting types" error yogi.aash Linux - Newbie 2 05-31-2010 06:25 PM
sys/types.h & linux/types.h conflict while compiling johnnyhal Linux - Software 1 12-28-2008 06:39 PM
conflicting redeclaration of sys/types.h and linux/types.h schmil Programming 6 12-11-2008 02:02 PM
conflicting types for check_state nasim751 Programming 2 02-11-2008 12:58 AM
error: conflicting types for `IPPROTO_IP' Anastasia Linux - Software 0 07-14-2005 06:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration