EmbDev.net

Forum: ARM programming with GCC/GNU tools warning: assignment from incompatible pointer type


von Kirkina A. (Company: no) (alya)


Rate this post
useful
not useful
I'm sick of this warning! Here's the code
1
struct passwd *pwd; 
2
3
code In function printLine:
4
gid_t gid = statbuf.st_gid;
5
        pwd = getgrgid(gid);
6
        if(pwd != NULL)
7
            printf("%s]", pwd->pw_name);
8
        else
9
            printf("%d]", statbuf.st_gid);
All prints correctly when executed. What needs to be corrected so that 
the selection disappears?
====
ls.c: In function ‘printLine’:
ls.c:225:13: warning: assignment from incompatible pointer type
         pwd = getgrgid(gid);
             ^

von Sebi (Guest)


Rate this post
useful
not useful
Whats the return type of getgrgid?

von (prx) A. K. (prx)


Rate this post
useful
not useful
struct group *

von Yalu X. (yalu) (Moderator)


Rate this post
useful
not useful
pwd seems to be of type

  struct passwd *

but getgrgid() returns

  struct group *

The first three elements of the two structs are similar, thus the code
still works.

von Kirkina A. (Company: no) (alya)


Rate this post
useful
not useful
Yalu X. wrote:
> pwd seems to be of type
>
>   struct passwd *
>
> but getgrgid() returns
>
>   struct group *
>
> The first three elements of the two structs are similar, thus the code
> still works.

Thanks

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.