linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* problems creating a driver
@ 2002-12-15 13:05 David Sanán Baena
  2002-12-15 15:49 ` David Gómez
  0 siblings, 1 reply; 2+ messages in thread
From: David Sanán Baena @ 2002-12-15 13:05 UTC (permalink / raw)
  To: linux-kernel

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: problems creating a driver
  2002-12-15 13:05 problems creating a driver David Sanán Baena
@ 2002-12-15 15:49 ` David Gómez
  0 siblings, 0 replies; 2+ messages in thread
From: David Gómez @ 2002-12-15 15:49 UTC (permalink / raw)
  To: David Sanán Baena; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-12-15 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-15 13:05 problems creating a driver David Sanán Baena
2002-12-15 15:49 ` David Gómez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).