dereferencing pointer to incomplete type?

dereferencing pointer to incomplete type?

Post by zZ-ZA » Sun, 25 Apr 1999 04:00:00



Hi!

I'm writting a simple program to post articles to a NNTP server with the
post command. I want to change both my uid a gid to news. I'm trying to do
it in the following way:

--- CUT ---

struct passwd *pw;

pw = getpwnam("news");        
  if (!pw)
    {
       printf("No user 'news'. Aborting...\n\n");
       exit(0);
    }
setregid( pw->pw_gid, pw->pw_gid );
setreuid( pw->pw_uid, pw->pw_uid );

--- CUT ---

But when I compile I get the following errors:

--- CUT ---

nntp-post.c: In function `init':
nntp-post.c:109: warning: assignment makes pointer from integer without a cast
nntp-post.c:115: dereferencing pointer to incomplete type
nntp-post.c:115: dereferencing pointer to incomplete type
nntp-post.c:116: dereferencing pointer to incomplete type
nntp-post.c:116: dereferencing pointer to incomplete type

--- CUT ---

What does 'dereferencing pointer to incomplete type' mean? What am I doing
wrong?

Thanks
Lloyd

 
 
 

dereferencing pointer to incomplete type?

Post by George MacDonal » Sun, 25 Apr 1999 04:00:00



> Hi!

> I'm writting a simple program to post articles to a NNTP server with the
> post command. I want to change both my uid a gid to news. I'm trying to do
> it in the following way:

> --- CUT ---

> struct passwd *pw;

> pw = getpwnam("news");
>   if (!pw)
>     {
>        printf("No user 'news'. Aborting...\n\n");
>        exit(0);
>     }
> setregid( pw->pw_gid, pw->pw_gid );
> setreuid( pw->pw_uid, pw->pw_uid );

> --- CUT ---

> But when I compile I get the following errors:

> --- CUT ---

> nntp-post.c: In function `init':
> nntp-post.c:109: warning: assignment makes pointer from integer without a cast
> nntp-post.c:115: dereferencing pointer to incomplete type
> nntp-post.c:115: dereferencing pointer to incomplete type
> nntp-post.c:116: dereferencing pointer to incomplete type
> nntp-post.c:116: dereferencing  pointer to incomplete type

> --- CUT ---

> What does 'dereferencing pointer to incomplete type' mean? What am I doing
> wrong?

> Thanks
> Lloyd

You might want to add

#include <unistd.h>

--
We stand on the shoulders of those giants who coded before.
Build a good layer, stand strong, and prepare for the next wave.
Guide those who come after you, give them your shoulder, lend them your code.


 
 
 

dereferencing pointer to incomplete type?

Post by NF Steve » Sun, 25 Apr 1999 04:00:00


[snip]

Quote:>What does 'dereferencing pointer to incomplete type' mean? What am I doing
>wrong?

It means the compiler has not seen the definition of the
structure so it does not know its internal layout. You
need to include the header file in which the definition
occurs. In this case it is pwd.h. i.e. add the line

#include <pwd.h>

to your .c file.

Norman

 
 
 

dereferencing pointer to incomplete type?

Post by Arthur Rabati » Tue, 27 Apr 1999 04:00:00



> What does 'dereferencing pointer to incomplete type' mean? What am I doing
> wrong?

struct passwd *pw;

is declared but not defined. you must somewhere define
the struct.

'incomplete types' allow you to declare a type in your .h file
but implement it in your .cc file. Thus, the implementation is
fully hidden from users of that unit. But you cannot use
the implementation unless the compiler has seen it once. So
in a header file, referring to reference or pointer is fine. Using
by value or accessing data members does not work.

Arthur

Rabatin Investment Technology Ltd      
http://www.rabatin.com

 
 
 

1. : dereferencing pointer to incomplete type

Hi,

I am trying to make a sense out of the following partial code:

        #include <dirent.h>
        dirent *dp;
        if (!strcmp(dp->d_name, ".")) continue;
                .
                :

And, the compiler (gcc-2.95 on an i386 Linux)) complained with the
following error message:

        dereferencing pointer to incomplete type

I am just trying to learn C and got stuck with such an error.  If you can
shed some lights in this matter, I certainly will appreicate it.

TIA.

2. IP tunnel

3. 2.5.5 -- filesystems.c:30: In function `sys_nfsservctl': dereferencing pointer to incomplete type

4. Identd for NCR SVR4 3.0

5. Dereferencing pointer to incomplete type

6. USA_RESIDENT keeps getting reset to NO

7. how to determine if a file is a symbolic link (in C programs)

8. 2.5.18 -- build failure -- suspend.c:1052: dereferencing pointer to incomplete type

9. Solving "dereferencing pointer to incomplete type" error

10. "dereferencing pointer to incomplete type"

11. wu-ftpd.2.4 on linux compile error. ( dereferencing pointer to incomplete type)

12. Please help!! structure datatype scope (dereferencing pointer to incomplete type)