Sponsored Content
Top Forums Programming Accesing structure member:Error:dereferencing pointer to incomplete type Post 302116617 by amit4g on Monday 7th of May 2007 06:04:19 AM
Old 05-07-2007
Accesing structure member:Error:dereferencing pointer to incomplete type

[amit@localhost cprg]$ gcc -Wall -Werror struct.c
struct.c: In function `main':
struct.c:18: error: dereferencing pointer to incomplete type

[amit@localhost cprg]$ cat struct.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*Declaration of structure*/

struct human
{
char *first;
char gender[10];
int age;
} man, *p_human;

struct man *p_man;
int main(void)
{
strcpy(man.gender,"Male");
printf("%s\n",man.gender);
printf("%s\n",p_man->gender); <----------
exit(EXIT_SUCCESS);
}

The "p_man" is pointer to structure "man".what am i missing here.

Thanks,
~amit
 

10 More Discussions You Might Find Interesting

1. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

2. Programming

error: field has incomplete type

Hello there, Here is how it goes - I have written a small test driver as an exercise to "Linux Device Drivers" and as a preparation for writing a real, functional driver. For the sake of seeing how far I got it working (I already implemented the open(0, read(), write() and ioctl() calls) I... (4 Replies)
Discussion started by: boyanov
4 Replies

3. Programming

pointer to structure example pls

Dear friends, First all I applogize for posting such a simple question , as I love this forum and forum participants thats why I am posting my problem here.. Why I am getting error when I remove the commented lines typedef unsigned int U; typedef struct {U c; U d;} vec32; ... (1 Reply)
Discussion started by: user_prady
1 Replies

4. Programming

error: field `fatx_i' has incomplete type

I'm trying to compile a 2.4.26 kernel but I have to apply two patches to it. The patches are: linux-2.4.26-xbox.patch openMosix-2.4.26-1 This is the reason that it doesn't compile. There is only one error but I'm not familiar with C or C++(Unfortunately only Java and some lower-level... (2 Replies)
Discussion started by: lateralus01
2 Replies

5. UNIX for Dummies Questions & Answers

Build Error: error: dereferencing pointer to incomplete type

I'm getting the following Error: prepare_pcap.c: In function `prepare_pkts': prepare_pcap.c:127: error: dereferencing pointer to incomplete type prepare_pcap.c:138: error: dereferencing pointer to incomplete type ==================================== This is the part of the relevant... (8 Replies)
Discussion started by: katwala
8 Replies

6. Programming

Dereferencing pointer to incomplete type

// Hello all, I am having this error "Dereferencing pointer to incomplete type " on these 2 lines: xpoint = my_point->x; ypoint = my_point->y; I am having no clue y this is happening. Any help would be greately appreciated!!!! #include<stdio.h> #include<string.h>... (2 Replies)
Discussion started by: mind@work
2 Replies

7. Programming

Dereferencing pointer to a shared memory struct

I have what should be a relatively simple program (fadec.c) that maps a struct from an included header file (fadec.h) to a shared memory region, but I’m struggling accessing members in the struct from the pointer returned by shmat. Ultimately, I want to access members in the shared memory structure... (2 Replies)
Discussion started by: arette
2 Replies

8. Programming

Compilation Error: dereferencing pointer to incomplete type

I am getting a dereferencing pointer to incomplete type error when i compile the following code on lines highlighted in red. Can anyone help me in identifying what is wrong in the code? #include<stdio.h> #include<stdlib.h> typedef struct{ int info; struct node* link ; } node; void... (3 Replies)
Discussion started by: sreeharshasn
3 Replies

9. Programming

Declare member of struct as a pointer in c

I have a uint8_t *C = malloc(24*sizeof(uint8_t)); I need to send some integers and this *C to another node(in ad hoc network). So I am going to use a struct ` struct fulMsg { int msgType; int msgCount; //uint8_t *CC; } fulMsg_t; typedef struct fulMsg fulMsg_tt;` there is a method... (1 Reply)
Discussion started by: chap
1 Replies

10. Programming

Traversing member of structure of vector C++

Hello, I want to loop thru a vector composed of many entries as structure, which contains sequenceID and sequence. At looping, delete any structure if the sequence is a perfect-match substring of another sequence of any other structure, so that the resulted vector contains only unique sequences.... (1 Reply)
Discussion started by: yifangt
1 Replies
GETGRENT_R(3)						     Linux Programmer's Manual						     GETGRENT_R(3)

NAME
getgrent_r, fgetgrent_r - get group file entry reentrantly SYNOPSIS
#include <grp.h> int getgrent_r(struct group *gbuf, char *buf, size_t buflen, struct group **gbufp); int fgetgrent_r(FILE *fp, struct group *gbuf, char *buf, size_t buflen, struct group **gbufp); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): getgrent_r(): _GNU_SOURCE fgetgrent_r(): _SVID_SOURCE DESCRIPTION
The functions getgrent_r() and fgetgrent_r() are the reentrant versions of getgrent(3) and fgetgrent(3). The former reads the next group entry from the stream initialized by setgrent(3). The latter reads the next group entry from the stream fp. The group structure is defined in <grp.h> as follows: struct group { char *gr_name; /* group name */ char *gr_passwd; /* group password */ gid_t gr_gid; /* group ID */ char **gr_mem; /* group members */ }; For more information about the fields of this structure, see group(5). The nonreentrant functions return a pointer to static storage, where this static storage contains further pointers to group name, password and members. The reentrant functions described here return all of that in caller-provided buffers. First of all there is the buffer gbuf that can hold a struct group. And next the buffer buf of size buflen that can hold additional strings. The result of these functions, the struct group read from the stream, is stored in the provided buffer *gbuf, and a pointer to this struct group is returned in *gbufp. RETURN VALUE
On success, these functions return 0 and *gbufp is a pointer to the struct group. On error, these functions return an error value and *gbufp is NULL. ERRORS
ENOENT No more entries. ERANGE Insufficient buffer space supplied. Try again with larger buffer. CONFORMING TO
These functions are GNU extensions, done in a style resembling the POSIX version of functions like getpwnam_r(3). Other systems use proto- type struct group *getgrent_r(struct group *grp, char *buf, int buflen); or, better, int getgrent_r(struct group *grp, char *buf, int buflen, FILE **gr_fp); NOTES
The function getgrent_r() is not really reentrant since it shares the reading position in the stream with all other threads. EXAMPLE
#define _GNU_SOURCE #include <grp.h> #include <stdio.h> #include <stdlib.h> #define BUFLEN 4096 int main(void) { struct group grp, *grpp; char buf[BUFLEN]; int i; setgrent(); while (1) { i = getgrent_r(&grp, buf, BUFLEN, &grpp); if (i) break; printf("%s (%d):", grpp->gr_name, grpp->gr_gid); for (i = 0; ; i++) { if (grpp->gr_mem[i] == NULL) break; printf(" %s", grpp->gr_mem[i]); } printf(" "); } endgrent(); exit(EXIT_SUCCESS); } SEE ALSO
fgetgrent(3), getgrent(3), getgrgid(3), getgrnam(3), putgrent(3), group(5) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2010-10-21 GETGRENT_R(3)
All times are GMT -4. The time now is 11:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy