compiling errors cannot understand

R

rashmi

Hello All,
tp.c:107: error: syntax error before '*' token
tp.c:108: warning: function declaration isn't a prototype
tp.c:121: error: syntax error before '*' token
tp.c:122: warning: function declaration isn't a prototype
tp.c:135: error: syntax error before '*' token
tp.c:138: warning: return type defaults to `int'
tp.c:138: warning: no previous prototype for 'test_modevent'
tp.c: In function `test_modevent':
tp.c:143: warning: assignment from incompatible pointer type
*** Error code 1
***************************************************
This is the error code that i am getting on gcc conpiler but i dont
understand what could be wrong
i also attach that part of the code here
***************************************************
struct drv_t {
char name [8];
struct cdev *devt;
};

//static void test_ifstart (drv_t *d);
//static void test_ifwatchdog (drv_t *d);
//static void test_initialize (void *softc);
//static int test_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data);

static void test_ifstart (drv_t *d)
{


uprintf("inside start\n");
return;

}



Kindly help me in sorting this problem
Thanks and regards,
Rashmi
 
U

Ulrich Eckhardt

rashmi said:
tp.c:107: error: syntax error before '*' token [...]
struct drv_t {
char name [8];
struct cdev *devt;
}; [...]
static void test_ifstart (drv_t *d)

In C (other than in C++) a struct/union/enum does not introduce a new type.
Therefore, you need to write
static void test_ifstart (struct drv_t *d)
or use a typedef to make it a type:
typedef struct drv_t drv_t;

Uli
 
P

Peter Nilsson

Ulrich said:
rashmi said:
tp.c:107: error: syntax error before '*' token [...]
struct drv_t {
char name [8];
struct cdev *devt;
}; [...]
static void test_ifstart (drv_t *d)

In C (other than in C++) a struct/union/enum does not introduce a
new type.

Yes, it does.
Therefore, you need to write
static void test_ifstart (struct drv_t *d)
or use a typedef to make it a type:
typedef struct drv_t drv_t;

This is because struct tags are not visible as automatic typedef names
(or whatever C++ does), not because struct is not a new type.
 
K

Keith Thompson

Ulrich Eckhardt said:
rashmi said:
tp.c:107: error: syntax error before '*' token [...]
struct drv_t {
char name [8];
struct cdev *devt;
}; [...]
static void test_ifstart (drv_t *d)

In C (other than in C++) a struct/union/enum does not introduce a new type.

Yes, it does introduce a new type. The difference is that the tag is
in a separate namespace; it's not directly visible without the
struct/union/enum keyword in front of it.
Therefore, you need to write
static void test_ifstart (struct drv_t *d)
or use a typedef to make it a type:
typedef struct drv_t drv_t;

Right.

It's often argued that the typedef is a bad idea. It serves to hide
the fact that the type is a struct; it's usually better to make that
explicit.
 
I

Irrwahn Grausewitz

Ulrich Eckhardt said:
In C [...] a struct/union/enum does not introduce a new type.

On the contrary, as already correctly pointed out by others.

To put even more emphasis on the fact that these keywords actually
declare new types: it can be (and has been, e.g. by Chris Torek)
argued, that it's reasonable to think of "struct" actually /meaning/
"type"!
[...] you need to write
static void test_ifstart (struct drv_t *d)
or use a typedef to make it a type:
typedef struct drv_t drv_t;

Right. Notice however, that the keyword "typedef" does not declare a
new type, but merely declares a typename-alias for an existing type,
covering up the nature of this type. This is often considered a Bad
Thing[tm] to do, at least by a significant number of regulars in this
group, AFAICT.

Best Regards.
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top