EmbDev.net

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


Author: Kirkina Alya (Company: no) (alya)
Posted on:

Rate this post
0 useful
not useful
I'm sick of this warning! Here's the code
struct passwd *pwd; 

code In function printLine:
gid_t gid = statbuf.st_gid;
        pwd = getgrgid(gid);
        if(pwd != NULL)
            printf("%s]", pwd->pw_name);
        else
            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);
             ^

: Edited by User
Author: Sebi (Guest)
Posted on:

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

Author: A. K. (prx)
Posted on:

Rate this post
0 useful
not useful
struct group *

Author: Yalu X. (yalu) (Moderator)
Posted on:

Rate this post
0 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.

Author: Kirkina Alya (Company: no) (alya)
Posted on:

Rate this post
0 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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig