Problem with: dereferencing pointer to incomplete type 
Author Message
 Problem with: dereferencing pointer to incomplete type

Hi,
at using make i get following error:
gcc  -O2 -Wall -I../inc -I/usr/include/openssl   -c -o hLdap.o hLdap.c
hLdap.c: In function `LdapLimits':
hLdap.c:168: dereferencing pointer to incomplete type
hLdap.c:169: dereferencing pointer to incomplete type
hLdap.c:172: dereferencing pointer to incomplete type
hLdap.c:173: dereferencing pointer to incomplete type
make: *** [hLdap.o] Error 1

Here there are following sourcecodes (only parts of it):
In file "ldap.h":
typedef struct ldap {
        Sockbuf         ld_sb;          
        char            *ld_host;
        int             ld_version;
        char            ld_lberoptions;
        int             ld_deref;
        int             ld_timelimit;
        int             ld_sizelimit;
...

Quote:
} LDAP;

In file "ldap.c":
...
#include "ldap.h"
...
static LDAP   *pstLdap_m = NULL;
...

void    LdapLimits(
        int     iTime,
        int     iSize)
{
    pstLdap_m->ld_timelimit = iTime;      // <- line 168
    pstLdap_m->ld_sizelimit = iSize;      // <- line 169

    TrcPrint( TrcDat, "LDAP limits = (%d, %d)",
        pstLdap_m->ld_timelimit,          // <- line 172
        pstLdap_m->ld_sizelimit );        // <- line 173

    TRC_RET_VOID;

Quote:
}

...

I don't understand it, because it seems right.
Maybe somebody can help me?????????



Sat, 12 Nov 2005 21:52:23 GMT  
 Problem with: dereferencing pointer to incomplete type

| at using make i get following error:
...
| hLdap.c:168: dereferencing pointer to incomplete type
| hLdap.c:169: dereferencing pointer to incomplete type
| hLdap.c:172: dereferencing pointer to incomplete type
| hLdap.c:173: dereferencing pointer to incomplete type
...
| Here there are following sourcecodes (only parts of it):

The source code snippets you've posted seem perfectly ok.
The following extract compiles without problem:

typedef struct ldap {
  /* Sockbuf ld_sb; */
  char *ld_host;
  int ld_version;
  char ld_lberoptions;
  int ld_deref;
  int ld_timelimit;
  int ld_sizelimit;

Quote:
} LDAP;

static LDAP   *pstLdap_m = 00;

void    LdapLimits(
  int     iTime,
  int     iSize)
{
    pstLdap_m->ld_timelimit = iTime;      // <- line 168
    pstLdap_m->ld_sizelimit = iSize;      // <- line 169

Quote:
}

| I don't understand it, because it seems right.
| Maybe somebody can help me?????????

It does seem ok. Somehow, it appears that the definition
of LDAP has not been seen when the body of LdapLimits
gets compiled. Can't say more from your code snippet.

Try moving this struct definition around,
and watch for preprocessor directives (e.g. #ifdef)
that might be disabling some code sections...

hth,
--
 Ivan Vecerina, Dr. med.  <>  http://www.post1.com/~ivec
 Soft Dev Manger, xitact  <>  http://www.xitact.com
 Brainbench MVP for C++   <>  http://www.brainbench.com



Sat, 12 Nov 2005 22:37:34 GMT  
 Problem with: dereferencing pointer to incomplete type

Quote:
>Hi,
>at using make i get following error:
>gcc  -O2 -Wall -I../inc -I/usr/include/openssl   -c -o hLdap.o hLdap.c
>hLdap.c: In function `LdapLimits':
>hLdap.c:168: dereferencing pointer to incomplete type
>hLdap.c:169: dereferencing pointer to incomplete type
>hLdap.c:172: dereferencing pointer to incomplete type
>hLdap.c:173: dereferencing pointer to incomplete type
>make: *** [hLdap.o] Error 1

>Here there are following sourcecodes (only parts of it):
>In file "ldap.h":
>typedef struct ldap {
>    Sockbuf         ld_sb;          
>    char            *ld_host;
>    int             ld_version;
>    char            ld_lberoptions;
>    int             ld_deref;
>    int             ld_timelimit;
>    int             ld_sizelimit;
>...
>} LDAP;

My guess is that this definition is "protected" by some #if/#ifdef and
your code is "seeing" a different definition for LDAP.

Dan
--
Dan Pop
DESY Zeuthen, RZ group



Sat, 12 Nov 2005 22:40:17 GMT  
 Problem with: dereferencing pointer to incomplete type

Quote:

> Hi,
> at using make i get following error:
> gcc  -O2 -Wall -I../inc -I/usr/include/openssl   -c -o hLdap.o hLdap.c
> hLdap.c: In function `LdapLimits':
> hLdap.c:168: dereferencing pointer to incomplete type
> hLdap.c:169: dereferencing pointer to incomplete type
> hLdap.c:172: dereferencing pointer to incomplete type
> hLdap.c:173: dereferencing pointer to incomplete type
> make: *** [hLdap.o] Error 1

> Here there are following sourcecodes (only parts of it):
> In file "ldap.h":
> typedef struct ldap {
> Sockbuf               ld_sb;
> char          *ld_host;
> int           ld_version;
> char          ld_lberoptions;
> int           ld_deref;
> int           ld_timelimit;
> int           ld_sizelimit;
> ...
> } LDAP;

> In file "ldap.c":
> ...
> #include "ldap.h"
> ...
> static LDAP   *pstLdap_m = NULL;
> ...

> void    LdapLimits(
> int     iTime,
> int     iSize)
> {
>     pstLdap_m->ld_timelimit = iTime;      // <- line 168
>     pstLdap_m->ld_sizelimit = iSize;      // <- line 169

>     TrcPrint( TrcDat, "LDAP limits = (%d, %d)",
> pstLdap_m->ld_timelimit,          // <- line 172
> pstLdap_m->ld_sizelimit );        // <- line 173

>     TRC_RET_VOID;
> }

> ...

> I don't understand it, because it seems right.
> Maybe somebody can help me?????????

<OT>
I have ldap.h on my system in /usr/include. So I would include it using <>
instead of "". I never used it but suspect that you are looking where you
are not suposed to. Are you sure you are allowed to mess with the members
of an LDAP or is it an opaque type like a FILE?
<\OT>
Tobias.

--
unix http://www.faqs.org/faqs/by-newsgroup/comp/comp.unix.programmer.html
clc http://www.eskimo.com/~scs/C-faq/top.html
fclc (french): http://www.isty-info.uvsq.fr/~rumeau/fclc/



Sat, 12 Nov 2005 22:51:15 GMT  
 Problem with: dereferencing pointer to incomplete type

Quote:
><OT>
>I have ldap.h on my system in /usr/include.

So, you conclude that the OP must have it, too...

    fangorn:~ 1251> ls /usr/include/ldap.h
    ls: /usr/include/ldap.h: No such file or directory

Quote:
>So I would include it using <> instead of "".

If the "" search fails, another search is automatically performed for <>.

The "" syntax typically gives precedence to the application's directories,
the <> syntax typically gives precedence to the implementation's
directories.  So, you make your choice based on what you want to override
what.

Quote:
>I never used it but suspect that you are looking where you
>are not suposed to. Are you sure you are allowed to mess with the members
>of an LDAP or is it an opaque type like a FILE?

It's "ldap.h" that decides that.  And FILE is only a conceptually opaque
type, there is nothing in the standard preventing an implementation from
making its definition available to the program.  Furthermore, it CANNOT
be defined as an incomplete type, because the standard defines it as an
object type.

Dan
--
Dan Pop
DESY Zeuthen, RZ group



Sun, 13 Nov 2005 01:12:13 GMT  
 Problem with: dereferencing pointer to incomplete type

Quote:



>><OT>
>>I have ldap.h on my system in /usr/include.

> So, you conclude that the OP must have it, too...

I don't conclude anything. I just state that I have one there.

Quote:

>     fangorn:~ 1251> ls /usr/include/ldap.h
>     ls: /usr/include/ldap.h: No such file or directory

>>So I would include it using <> instead of "".

> If the "" search fails, another search is automatically performed for <>.

Thanks for clarifing that. From now on I'll write include "stdio.h" because
the compiler will find it anyway.

Quote:
> The "" syntax typically gives precedence to the application's directories,
> the <> syntax typically gives precedence to the implementation's
> directories.  So, you make your choice based on what you want to override
> what.

>>I never used it but suspect that you are looking where you
>>are not suposed to. Are you sure you are allowed to mess with the members
>>of an LDAP or is it an opaque type like a FILE?

> It's "ldap.h" that decides that.  And FILE is only a conceptually opaque
> type, there is nothing in the standard preventing an implementation from
> making its definition available to the program.  

True. But any program that accesses these fields will not be portable since
these fields are not standardized.

Quote:
> Furthermore, it CANNOT
> be defined as an incomplete type, because the standard defines it as an
> object type.

The language lawyers will agree but it doesn't make a difference to somebody
writing code, from a practical point of view it's opaque.
Tobias.

--
unix http://www.faqs.org/faqs/by-newsgroup/comp/comp.unix.programmer.html
clc http://www.eskimo.com/~scs/C-faq/top.html
fclc (french): http://www.isty-info.uvsq.fr/~rumeau/fclc/



Mon, 14 Nov 2005 00:04:01 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. HELP?! Problem with dereferencing pointer to incomplete type

2. Dereferencing pointer to incomplete type

3. "dereferencing pointer to incomplete type"

4. struct datatype scope (dereferencing pointer to incomplete type)

5. gcc: dereferencing pointer to incomplete type

6. dereferencing pointer to incomplete type

7. dereferencing pointer to incomplete type

8. dereferencing pointer to incomplete type

9. dereferencing pointer to incomplete type

10. dereferencing pointer to incomplete type

11. --Dereferencing point to incomplete type

12. type casting to / from pointers to incomplete data types

 

 
Powered by phpBB® Forum Software