c: structs func and pointers

hi all,
I've a truble with slimilar of this code..
1
2
3
4
5
6
7
8
struct first *fir;
struct second *sec;
func(struct firs *fi, struct s *se){
......
return func(fi,se); // return value from func which take pointer on struct firs  and s
}
errno=func(fir,sec); // take pointer on struct first  and second
//warning: passing argument 2 of 'func' from incompatible pointer type 

I wrote two equal methog structs usage, but second take it's warning. Why it's happened?
In line 7, sec is a 'second *', but func() takes an 's *' as the second parameter.

By the way, 'first', 'second', 'firs', and 's'? Were those the most meaningless names you could come up with?
In line 7, sec is a 'second *', but func() takes an 's *' as the second parameter.

hm, why myfunc take first parameter very well and broke on second?
I made something this
errno=func(fir,(struct second*)&sec);
and this
errno=func(fir,&sec);
but it's doesnt' work.
By the way, 'first', 'second', 'firs', and 's'? Were those the most meaningless names you could come up with?

I wrote just a simple like my code.
Last edited on
Meaningless variable names are the antithesis to simplicity.
why?
It's not essential with it.
1
2
3
4
5
6
7
struct numbers *seq;
struct data *buf;
int main(struct num *x, struct str *y){
......
return main(x,y);
}
errno=func(sec,buf);

How I can use function main which be able take second argument buf, are type of struct str?
main() is a reserved symbol/"function" that can only take certain arguments, namely

int argc, char* argv[], char** arge

or

int argc, char* argv[]

or

no parameters

So you can't write line 3 above; you need to name the function differently.

Also, it is not allowed by the standard to call main() from within your program. Not all compilers adhere to that rule, however.

yes, it's very well, but warning provoke when I tride use function in another function.
1
2
3
4
5
6
7
struct numbers *seq;
struct data *buf;
int my_func(struct num *x, struct str *y){
......
return my_func(x,y);
}
errno=my_func(sec,buf);
Then you have a syntactic error in your code.
my god, where? Warning is appeared when I call my_func here...
errno=my_func(sec,buf); //warning: passing argument 2 of 'my_func' from incompatible pointer type
Well, the warning is fairly explicit.

my_func takes a pointer-to-something as its second parameter, but buf is a pointer-to-something-else.

Curiously enough, that's exactly what I said in my first post.
Curiously enough, that's exactly what I said in my first post.
In line 7, sec is a 'second *', but func() takes an 's *' as the second parameter.
helios, ok. Just I want to understood, which's method I gotta use there so as to replace that?
1
2
3
4
5
6
7
struct first *fir;
struct second *sec;
func(struct firs *fi, struct s se){ // if I do that, its not improve situation.
......
return func(fi,&se);
}
errno=func(fir,sec);// me need doing something with second argument here, but I don't know how. 
Topic archived. No new replies allowed.