Conflicting types.h

798 views
Skip to first unread message

P-GPS

unread,
Nov 12, 2010, 5:23:30 PM11/12/10
to Comedi: Linux Control and Measurement Device Interface
I am trying to build some programs in RTAI. COMEDI is installed. I
find a lot of redefinition / declaration errors.

Essentially, comedilib.h includes types.h from glibc while RTAI
includes types.h from kernel. Unfortunately these 2 types.h seems to
be incompatible.

Problem is similar to this message: http://mail.rtai.org/pipermail/rtai/2007-December/018309.html

Below are the locations of comedilib.h

# locate comedilib.h
/usr/local/include/comedilib.h
/usr/local/include/comedilib.hpp
/usr/local/include/linux/comedilib.h
/usr/local/src/comedi/include/linux/comedilib.h
/usr/local/src/comedilib/c++/include/comedilib.hpp
/usr/local/src/comedilib/include/comedilib.h


My output of "make" is after this message. Can someone point me where
I am going wrong.

Thanks.

# make
make -C /lib/modules/`uname -r`/build M=`pwd` "/usr/src/linux"
SUBDIRS="/home/user01/Desktop/exampleProgs/ex13_comedi" modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-122-rtai'
make[1]: Nothing to be done for `/usr/src/linux'.
CC [M] /home/user01/Desktop/exampleProgs/ex13_comedi/comedi_task.o
In file included from /usr/include/features.h:346,
from /usr/include/sys/ioctl.h:22,
from /usr/local/include/linux/comedilib.h:29,
from /home/user01/Desktop/exampleProgs/ex13_comedi/
comedi_task.c:19:
/usr/include/sys/cdefs.h:287:1: warning: "__always_inline" redefined
In file included from include/linux/compiler-gcc.h:86,
from include/linux/compiler.h:40,
from include/linux/linkage.h:4,
from include/linux/kernel.h:11,
from /home/user01/Desktop/exampleProgs/ex13_comedi/
comedi_task.c:13:
include/linux/compiler-gcc4.h:15:1: warning: this is the location of
the previous definition
In file included from /usr/include/bits/fcntl.h:24,
from /usr/include/fcntl.h:34,
from /usr/local/include/linux/comedilib.h:30,
from /home/user01/Desktop/exampleProgs/ex13_comedi/
comedi_task.c:19:
/usr/include/sys/types.h:35: error: redefinition of typedef ‘u_char’
include/linux/types.h:88: note: previous declaration of ‘u_char’ was
here
/usr/include/sys/types.h:36: error: redefinition of typedef ‘u_short’
include/linux/types.h:89: note: previous declaration of ‘u_short’ was
here
/usr/include/sys/types.h:37: error: redefinition of typedef ‘u_int’
include/linux/types.h:90: note: previous declaration of ‘u_int’ was
here
/usr/include/sys/types.h:38: error: redefinition of typedef ‘u_long’
include/linux/types.h:91: note: previous declaration of ‘u_long’ was
here
/usr/include/sys/types.h:46: error: redefinition of typedef ‘loff_t’
include/linux/types.h:50: note: previous declaration of ‘loff_t’ was
here
/usr/include/sys/types.h:50: error: redefinition of typedef ‘ino_t’
include/linux/types.h:22: note: previous declaration of ‘ino_t’ was
here
/usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’
include/linux/types.h:21: note: previous declaration of ‘dev_t’ was
here
/usr/include/sys/types.h:67: error: redefinition of typedef ‘gid_t’
include/linux/types.h:37: note: previous declaration of ‘gid_t’ was
here
/usr/include/sys/types.h:72: error: conflicting types for ‘mode_t’
include/linux/types.h:23: note: previous declaration of ‘mode_t’ was
here
/usr/include/sys/types.h:77: error: conflicting types for ‘nlink_t’
include/linux/types.h:24: note: previous declaration of ‘nlink_t’ was
here
/usr/include/sys/types.h:82: error: redefinition of typedef ‘uid_t’
include/linux/types.h:36: note: previous declaration of ‘uid_t’ was
here
/usr/include/sys/types.h:88: error: redefinition of typedef ‘off_t’
include/linux/types.h:25: note: previous declaration of ‘off_t’ was
here
/usr/include/sys/types.h:100: error: redefinition of typedef ‘pid_t’
include/linux/types.h:26: note: previous declaration of ‘pid_t’ was
here
/usr/include/sys/types.h:110: error: redefinition of typedef ‘ssize_t’
include/linux/types.h:64: note: previous declaration of ‘ssize_t’ was
here
/usr/include/sys/types.h:116: error: redefinition of typedef ‘daddr_t’
include/linux/types.h:27: note: previous declaration of ‘daddr_t’ was
here
/usr/include/sys/types.h:117: error: redefinition of typedef ‘caddr_t’
include/linux/types.h:84: note: previous declaration of ‘caddr_t’ was
here
/usr/include/sys/types.h:123: error: redefinition of typedef ‘key_t’
include/linux/types.h:28: note: previous declaration of ‘key_t’ was
here
In file included from /usr/include/sys/types.h:133,
from /usr/include/bits/fcntl.h:24,
from /usr/include/fcntl.h:34,
from /usr/local/include/linux/comedilib.h:30,
from /home/user01/Desktop/exampleProgs/ex13_comedi/
comedi_task.

Ian Abbott

unread,
Nov 13, 2010, 5:51:34 AM11/13/10
to comed...@googlegroups.com
> /usr/include/sys/types.h:35: error: redefinition of typedef �u_char�
> include/linux/types.h:88: note: previous declaration of �u_char� was
> here
> /usr/include/sys/types.h:36: error: redefinition of typedef �u_short�
> include/linux/types.h:89: note: previous declaration of �u_short� was
> here
> /usr/include/sys/types.h:37: error: redefinition of typedef �u_int�
> include/linux/types.h:90: note: previous declaration of �u_int� was
> here
> /usr/include/sys/types.h:38: error: redefinition of typedef �u_long�
> include/linux/types.h:91: note: previous declaration of �u_long� was
> here
> /usr/include/sys/types.h:46: error: redefinition of typedef �loff_t�
> include/linux/types.h:50: note: previous declaration of �loff_t� was
> here
> /usr/include/sys/types.h:50: error: redefinition of typedef �ino_t�
> include/linux/types.h:22: note: previous declaration of �ino_t� was
> here
> /usr/include/sys/types.h:62: error: conflicting types for �dev_t�
> include/linux/types.h:21: note: previous declaration of �dev_t� was
> here
> /usr/include/sys/types.h:67: error: redefinition of typedef �gid_t�
> include/linux/types.h:37: note: previous declaration of �gid_t� was
> here
> /usr/include/sys/types.h:72: error: conflicting types for �mode_t�
> include/linux/types.h:23: note: previous declaration of �mode_t� was
> here
> /usr/include/sys/types.h:77: error: conflicting types for �nlink_t�
> include/linux/types.h:24: note: previous declaration of �nlink_t� was
> here
> /usr/include/sys/types.h:82: error: redefinition of typedef �uid_t�
> include/linux/types.h:36: note: previous declaration of �uid_t� was
> here
> /usr/include/sys/types.h:88: error: redefinition of typedef �off_t�
> include/linux/types.h:25: note: previous declaration of �off_t� was
> here
> /usr/include/sys/types.h:100: error: redefinition of typedef �pid_t�
> include/linux/types.h:26: note: previous declaration of �pid_t� was
> here
> /usr/include/sys/types.h:110: error: redefinition of typedef �ssize_t�
> include/linux/types.h:64: note: previous declaration of �ssize_t� was
> here
> /usr/include/sys/types.h:116: error: redefinition of typedef �daddr_t�
> include/linux/types.h:27: note: previous declaration of �daddr_t� was
> here
> /usr/include/sys/types.h:117: error: redefinition of typedef �caddr_t�
> include/linux/types.h:84: note: previous declaration of �caddr_t� was
> here
> /usr/include/sys/types.h:123: error: redefinition of typedef �key_t�
> include/linux/types.h:28: note: previous declaration of �key_t� was

> here
> In file included from /usr/include/sys/types.h:133,
> from /usr/include/bits/fcntl.h:24,
> from /usr/include/fcntl.h:34,
> from /usr/local/include/linux/comedilib.h:30,
> from /home/user01/Desktop/exampleProgs/ex13_comedi/
> comedi_task.
>

There are two different headers called comedilib.h:

1. The userland comedilib.h for accessing libcomedi - this header comes
from the comedilib package.

2. The kernel linux/comedilib.h for accessing the kcomedilib kernel
module from kernel-level code - this header comes from the comedi package.

You need to make sure your /usr/local/include/linux/comedilib.h comes
from the comedi sources, not the comedilib sources.

--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-

Yoshiya Matsuzaka

unread,
Nov 13, 2010, 7:31:35 AM11/13/10
to comed...@googlegroups.com
Hi P-GPS,

It looks like you are trying to build a kernel module. If this is
correct, you need to include comedi.h and comedilib.h under
/usr/local/include/linux, instead of those with the same names under
/usr/local/include. So in your source file(s), the include statements
should appear like this:

----- module.c -----
#include <linux/comedi.h>
#include <linux/comedilib.h>
.

And you need to define the include paths in the Makefile like below:
----- Makefile -----
KERNELSRCDIR = /usr/src/linux
BUILD_DIR := $(shell pwd)
VERBOSE = 1
# Assumes that the RTAI and COMEDI are installed in the default directories
EXTRA_CFLAGS = `/usr/realtime/bin/rtai-config --module-cflags`
-I/usr/local/include

I hope this solves your problem.

Yoshiya Matsuzaka

P-GPS

unread,
Nov 15, 2010, 2:43:15 PM11/15/10
to Comedi: Linux Control and Measurement Device Interface
Ian/Yoshiya, Thanks. Both your suggestions (combined) worked.

1. I had the wrong comedilib.h in /usr/local/include/linux/ . I fixed
this.
2. I didn't have #include <linux/comedi.h> in my code. And the
Makefile was modified with Yoshiya's suggestions above.

Thanks.


On Nov 13, 8:31 am, Yoshiya Matsuzaka <matsu...@med.tohoku.ac.jp>
wrote:
Reply all
Reply to author
Forward
0 new messages