compiling errors while initializing a structure has function pointers as members

R

rashmi

Hi All,
*************************************************
error: variable `hdlc_cdevsw' has initializer but incomplete type
***************************************************

This is the error that i'm getting while trying to compiling a driver
..inspite of this way of declaration being valid in gcc i'm getting this
error.
I have declared hdlc_open and defined CDEV_MAJOR prior to this .
static struct cdevsw hdlc_cdevsw = {
.d_name = "hdlc_cdev",
.d_maj = CDEV_MAJOR,
.d_open = hdlc_open;
};
I'm here by providing the cdevsw structure for ur refrence .kindly let me
know why this err is occuring .
Charac device structure
struct cdevsw {
int d_version;
int d_maj;
u_int d_flags;
const char *d_name;
d_open_t *d_open;
d_fdopen_t *d_fdopen;
d_close_t *d_close;
d_read_t *d_read;
d_write_t *d_write;
d_ioctl_t *d_ioctl;
d_poll_t *d_poll;
d_mmap_t *d_mmap;
d_strategy_t *d_strategy;
dumper_t *d_dump;
d_kqfilter_t *d_kqfilter;
d_spare1_t *d_spare1;
d_spare2_t *d_spare2;

/* These fields should not be messed with by drivers */
LIST_ENTRY(cdevsw) d_list;
LIST_HEAD(, cdev) d_devs;
int d_refcount;
};

kindly let me know what is the problem here
Thanks in Advance ,
RAshmi.N.S
 
A

Alexei A. Frounze

rashmi said:
Hi All,
*************************************************
error: variable `hdlc_cdevsw' has initializer but incomplete type
***************************************************

This is the error that i'm getting while trying to compiling a driver
.inspite of this way of declaration being valid in gcc i'm getting this
error.
I have declared hdlc_open and defined CDEV_MAJOR prior to this .
static struct cdevsw hdlc_cdevsw = {
.d_name = "hdlc_cdev",

^^^ dots aren't part of the name, they have special use -- when accessing
member of a structure but not when defining/declaring it. Remove the dots
here.

Alex
 
L

Lawrence Kirby

The error is saying that the structure type is incomplete i.e. the
compiler cannot see a definition (i.e. the specification of the
structure members) of struct cdevsw at this point.
^^^ dots aren't part of the name, they have special use -- when accessing
member of a structure but not when defining/declaring it. Remove the dots
here.

Dots aren't part of the name but they are part of the C99 named structure
member initialisation syntax so they are required here.

Lawrence
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top