|
|
compiling errors cannot understand
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
|
|
0
|
|
|
|
Reply
|
nsrashmi (17)
|
9/9/2005 5:13:56 AM |
|
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
|
|
0
|
|
|
|
Reply
|
doomster121 (274)
|
9/9/2005 5:17:30 AM
|
|
Thank you it really worked
--
rasmi
|
|
0
|
|
|
|
Reply
|
nsrashmi (17)
|
9/9/2005 5:33:08 AM
|
|
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
|
|
0
|
|
|
|
Reply
|
airia (1802)
|
9/9/2005 6:35:17 AM
|
|
Ulrich Eckhardt <doomster@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) kst-u@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.
|
|
0
|
|
|
|
Reply
|
kst-u (21460)
|
9/9/2005 7:01:02 AM
|
|
Ulrich Eckhardt <doomster@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 (irrwahn35@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.
|
|
0
|
|
|
|
Reply
|
irrwahn35 (78)
|
9/9/2005 8:25:52 AM
|
|
|
5 Replies
28 Views
(page loaded in 0.35 seconds)
|
|
|
|
|
|
|
|
|