LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Strange compiling problem (https://www.linuxquestions.org/questions/programming-9/strange-compiling-problem-631190/)

jaepi 03-28-2008 02:53 AM

Strange compiling problem
 
I tried compiling my program to ubuntu using gcc and i got no errors, how ever when i compile it to opensuse 10.3 I get these error:

/usr/include/sys/types.h:52: error: conflicting declaration ‘typedef __ino64_t ino_t’
/usr/include/linux/types.h:14: error: ‘ino_t’ has a previous declaration as ‘typedef __kernel_ino_t ino_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/sys/types.h:67: error: conflicting declaration ‘typedef __gid_t gid_t’
/usr/include/linux/types.h:27: error: ‘gid_t’ has a previous declaration as ‘typedef __kernel_gid_t gid_t’
/usr/include/sys/types.h:72: error: conflicting declaration ‘typedef __mode_t mode_t’
/usr/include/linux/types.h:15: error: ‘mode_t’ has a previous declaration as ‘typedef __kernel_mode_t mode_t’
/usr/include/sys/types.h:77: error: conflicting declaration ‘typedef __nlink_t nlink_t’
/usr/include/linux/types.h:16: error: ‘nlink_t’ has a previous declaration as ‘typedef __kernel_nlink_t nlink_t’
/usr/include/sys/types.h:82: error: conflicting declaration ‘typedef __uid_t uid_t’
/usr/include/linux/types.h:26: error: ‘uid_t’ has a previous declaration as ‘typedef __kernel_uid_t uid_t’
/usr/include/sys/types.h:90: error: conflicting declaration ‘typedef __off64_t off_t’
/usr/include/linux/types.h:17: error: ‘off_t’ has a previous declaration as ‘typedef __kernel_off_t off_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/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:248: error: conflicting declaration ‘typedef __blkcnt64_t blkcnt_t’
/usr/include/linux/types.h:114: error: ‘blkcnt_t’ has a previous declaration as ‘typedef long unsigned int blkcnt_t’

ta0kira 03-28-2008 08:01 AM

Looks like either you're compiling a module as if it were a program or vice-versa.
ta0kira

jaepi 03-31-2008 03:01 AM

exactly, i'm compiling a program sir. do you have any idea what seems to be the problem?

ta0kira 03-31-2008 11:44 AM

Do you include both <sys/types.h> and <linux/types.h> in the file that has the error? Please list the includes for the file that has the error, and also the includes for those files included (if they are your files, too.)
ta0kira

jaepi 03-31-2008 09:58 PM

I did'nt include both <sys/types.h> and <linux/types.h>. I am using sys/statvfs but I am also using something from <include/linux/> which is cdrom.h. could this be a problem?

jaepi 04-01-2008 12:10 AM

This is really weird because i can compile in Ubuntu but I can't compile in opensuse. What is the difference between these distribution? I can't really understand the conflict made.

ta0kira 04-01-2008 06:38 AM

What in <linux/cdrom.h> do you need that you can't get somewhere else?
ta0kira

KenJackson 04-01-2008 07:19 AM

The top of /usr/linux/cdrom.h on my (Mandriva) system has this:
Code:

/*******************************************************
 * As of Linux 2.1.x, all Linux CD-ROM application programs will use this
 * (and only this) include file.  ...

So apparently the author wants you to delete the #include lines for sys/types.h and sys/statvfs.h.

If that leaves some things undefined or undeclared, maybe you could break your file into two files and only include cdrom.h in one of them.

ta0kira 04-01-2008 11:23 AM

You need to make sure that anything that uses one version of a typedef isn't used by something that uses another. In other words, you should probably isolate the use of <linux/cdrom.h> to a single source file and give it an interface .h (if it even needs one) that doesn't use any of those typedefs to avoid malformed binary code. You'll have major problems if one source thinks a type is a different size or sign than another source does, which can easily happen with typedefs that differ source-to-source.
ta0kira


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