Hello and before of all thank you for read this.
First I use kernel 2.4.9
I have made a driver to change data betwen kernel and user space.
but when compiling I got the following message:
[david@localhost samplepackage]# make
c++ -w -Wall -fno-exceptions -fno-rtti -fvtable-thunks -DHAVE_CONFIG_H -I. -
I. -I. -I/usr/local/include -I/usr/local/share/click/src -I/usr/src/linux/in
clude -MD -DCLICK_LINUXMODULE -DCLICK_PACKAGE -O2 -c totcl.cc -o totcl.ko
totcl.cc:60: sorry, not implemented: non-trivial labeled initializers
totcl.cc:60: cannot convert `ssize_t (*) (file *, char *, unsigned int,
loff_t *)' to `module *' in initialization
totcl.cc:60: sorry, not implemented: non-trivial labeled initializers
totcl.cc:60: cannot convert `int (*) (inode *, file *)' to `loff_t (*)
(file *, long long int, int)' in initialization
totcl.cc:60: sorry, not implemented: non-trivial labeled initializers
totcl.cc:60: cannot convert `int (*) (inode *, file *)' to `ssize_t (*)
(file *, char *, unsigned int, loff_t *)' in initialization
make: *** [totcl.ko] Error 1
my file_operations var is:
struct file_operations totcl_fops=
{
read:totcl_read,
open:totcl_open,
release:totcl_release,
};
(I have seen this in many documents, even in linux files...)
when I removed the labels the "sorry, not implementd:non-trivial labeled
initializers" is not shown
And finally looking in "/usr/src/linux/include/linxu/fs.h"
I saw that with the first field is: module * own
so I have changed my file_operations var to:
static struct file_operations totcl_fops=
{ NULL,
NULL, /*seek*/
totcl_read,
NULL, /*write*/
NULL, /* readdir*/
NULL, /* select */
NULL, /* ioctl */
NULL, /*mmap*/
totcl_open,
NULL, /*fflush*/
totcl_release
};
And now it compiles well... I have not test the result, but first I would
want to know why doesn't work the first declaration (when It must be work,
or not?).
Could I have any problems later because that?
Thanks In advance
David
Hi David ;);
> totcl.cc:60: sorry, not implemented: non-trivial labeled initializers
> totcl.cc:60: cannot convert `int (*) (inode *, file *)' to `ssize_t (*)
> (file *, char *, unsigned int, loff_t *)' in initialization
> make: *** [totcl.ko] Error 1
I think the problem it's that designated initializers are not implemented in
the GNU c++ compiler, so you have to initialize all the field in the structure.
> my file_operations var is:
> struct file_operations totcl_fops=
> {
> read:totcl_read,
> open:totcl_open,
> release:totcl_release,
> };
By the way, C99 syntax is better, most of the kernel has been changed to the
new syntax:
struct file_operations totcl_fops=
{
.read=totcl_read,
.open=totcl_open,
.release=toctl_release,
};
--
David G?mez
"The question of whether computers can think is just like the question of
whether submarines can swim." -- Edsger W. Dijkstra