LinuxQuestions.org
Visit Jeremy's Blog.
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 05-09-2008, 09:01 AM   #1
schmil
LQ Newbie
 
Registered: May 2008
Distribution: fedora core 8
Posts: 5

Rep: Reputation: 0
conflicting redeclaration of sys/types.h and linux/types.h


Hi,

I wrote a program that uses both linux/if.h and netinet/ip.h
linux/if.h uses linux/types.h which conflict with sys/types.h used by netinet/ip.h

Any idea how to solve this problem?

Thanks
Schmil

compilation errors

/usr/include/sys/types.h:46: error: conflicting declaration ‘typedef __loff_t loff_t’
/usr/include/linux/types.h:30: error: ‘loff_t’ has a previous declaration as ‘typedef __kernel_loff_t loff_t’
/usr/include/sys/types.h:62: error: conflicting declaration ‘typedef __dev_t dev_t’
/usr/include/linux/types.h:13: error: ‘dev_t’ has a previous declaration as ‘typedef __kernel_dev_t dev_t’
/usr/include/time.h:105: error: conflicting declaration ‘typedef void* timer_t’
/usr/include/linux/types.h:22: error: ‘timer_t’ has a previous declaration as ‘typedef __kernel_timer_t timer_t’
/usr/include/sys/types.h:198: error: conflicting declaration ‘typedef long int int64_t’
/usr/include/linux/types.h:98: error: ‘int64_t’ has a previous declaration as ‘typedef __s64 int64_t’
/usr/include/sys/types.h:204: error: conflicting declaration ‘typedef long unsigned int u_int64_t’
/usr/include/linux/types.h:97: error: ‘u_int64_t’ has a previous declaration as ‘typedef __u64 u_int64_t’
/usr/include/sys/select.h:78: error: conflicting declaration ‘typedef struct fd_set fd_set’
/usr/include/linux/types.h:12: error: ‘fd_set’ has a previous declaration as ‘typedef struct __kernel_fd_set fd_set’
/usr/include/sys/types.h:235: error: conflicting declaration ‘typedef __blkcnt_t blkcnt_t’
/usr/include/linux/types.h:124: error: ‘blkcnt_t’ has a previous declaration as ‘typedef long unsigned int blkcnt_t’
/usr/include/bits/uio.h:44: error: redefinition of ‘struct iovec’
/usr/include/linux/uio.h:16: error: previous definition of ‘struct iovec’
/usr/include/bits/socket.h:150: error: redefinition of ‘struct sockaddr’
/usr/include/linux/socket.h:38: error: previous definition of ‘struct sockaddr’
/usr/include/bits/socket.h:167: error: redefinition of ‘struct __kernel_sockaddr_storage’
/usr/include/linux/socket.h:11: error: previous definition of ‘struct __kernel_sockaddr_storage’
/usr/include/bits/socket.h:178: error: expected identifier before numeric constant
/usr/include/bits/socket.h:178: error: expected `}' before numeric constant
/usr/include/bits/socket.h:178: error: expected unqualified-id before numeric constant
/usr/include/bits/socket.h:225: error: redefinition of ‘struct msghdr’
/usr/include/linux/socket.h:56: error: previous definition of ‘struct msghdr’
/usr/include/bits/socket.h:243: error: redefinition of ‘struct cmsghdr’
/usr/include/linux/socket.h:72: error: previous definition of ‘struct cmsghdr’
/usr/include/bits/socket.h:302: error: expected identifier before numeric constant
/usr/include/bits/socket.h:302: error: expected `}' before numeric constant
/usr/include/bits/socket.h:302: error: expected unqualified-id before numeric constant
/usr/include/bits/socket.h:308: error: expected declaration before ‘}’ token
 
Old 05-09-2008, 11:42 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

I don't get any conflict. Here's an example:
Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <netinet/ip.h>

int
main ()
{
  printf ("Hello world!\n");
}
  <= This compiles without error
Perhaps you might consider reinstalling/updating your GCC development package?

Also: make sure you haven't somehow mixed kernel source headers (which should be under "/usr/src/linux*") with user (non-kernel) headers (which should be under "/usr/include").

Last edited by paulsm4; 05-09-2008 at 11:44 AM.
 
Old 05-10-2008, 05:41 PM   #3
schmil
LQ Newbie
 
Registered: May 2008
Distribution: fedora core 8
Posts: 5

Original Poster
Rep: Reputation: 0
Hi,

How can I get the headers mixed, I icluded them as following:
#include <linux/if.h>
#include <netinet/ip.h>
 
Old 05-10-2008, 06:38 PM   #4
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Please try this:

1. Try compiling the above "Hello world".

2. If it fails with the same error, then consider de-installing your current gcc-dev package and re-installing (the latest/greatest) version.

You should be able to use the standard "<linux/if.h>" and "<netinet/ip.h>" headers together with no problem.

I suspect the problem is configuration, with the gcc-dev installation you have on your system.

IMHO .. PSM
 
Old 05-17-2008, 06:03 PM   #5
schmil
LQ Newbie
 
Registered: May 2008
Distribution: fedora core 8
Posts: 5

Original Poster
Rep: Reputation: 0
I used linux/ip.h and that solved the problem
But I'll try to reinstall GCC later

Thanks
 
Old 07-20-2008, 04:15 PM   #6
schmil
LQ Newbie
 
Registered: May 2008
Distribution: fedora core 8
Posts: 5

Original Poster
Rep: Reputation: 0
Unhappy I Though i solvedit

I thought that I solved it when I changed to linux/ip.h instead of netinet/ip.h
but lately I got into more trouble.
When I compile the small hello program below I don't have any problems
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <netinet/ip.h>

int
main ()
{
printf ("Hello world!\n");
}

Both programs use the same includes but only the Hello program compiles without errors????
 
Old 12-11-2008, 02:02 PM   #7
jsarao
LQ Newbie
 
Registered: Dec 2008
Posts: 1

Rep: Reputation: 0
I had the same problem. turns out it was an #include somewhere else in my project.

Try this:

do a complete search for "types.h" in all files in your project

I then made all of them

#include <sys/types.h>

and everything compiled.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
conflicting types for check_state nasim751 Programming 2 02-11-2008 12:58 AM
warning: conflicting types for ‘check_state’ nasim751 Programming 3 02-01-2008 01:49 PM
warning: conflicting types for ‘check_state nasim751 Programming 2 01-30-2008 08:02 PM
error: conflicting types for `IPPROTO_IP' Anastasia Linux - Software 0 07-14-2005 06:12 AM
conflicting types error in parser.c snecklifter Programming 6 04-08-2005 06:59 PM


All times are GMT -5. The time now is 10:23 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration