By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

compiling errors cannot understand

P: n/a
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

Nov 15 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
rashmi wrote:
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

Nov 15 '05 #2

P: n/a
Thank you it really worked
--
rasmi

Nov 15 '05 #3

P: n/a
Ulrich Eckhardt wrote:
rashmi wrote:
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.

--
Peter

Nov 15 '05 #4

P: n/a
Ulrich Eckhardt <do******@knuut.de> writes:
rashmi wrote:
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.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #5

P: n/a
Ulrich Eckhardt <do******@knuut.de> wrote:
[...]
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.
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc : http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc frequent answers: http://benpfaff.org/writings/clc.
Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.