Hi, list:
Just come across a strange problem when using prldap_init() in MozLDAP. The
problem is, ldap.h and ldappr.h must be included right after system includes,
like stdio.h, otherwise, it won't compile.
A typical scenario is:
===========================================================
/* Makefile */
...
INCDIRS += $(CM_WORKAREA)/thirdpty/ldap/1.3b/ldap/include \
$(CM_WORKAREA)/thirdpty/ldap/1.3b/ldap/include/nspr
...
/* aba_ldap_interface.c, wrong version */
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <sys/utsname.h>
#include <sys/time.h>
#include <pthread.h>
#include "cfgAttr.h"
#include "ldap.h"
#include "ldappr.h" //xq
...
/* compile result */
In file included from
/home/qxu/4.0_SP2/uk_dbl/thirdpty/ldap/1.3b/ldap/include/nspr/nspr.h:49,
from
/home/qxu/4.0_SP2/uk_dbl/thirdpty/ldap/1.3b/ldap/include/ldappr.h:26,
from aba_ldap_interface.c:131:
/home/qxu/4.0_SP2/uk_dbl/thirdpty/ldap/1.3b/ldap/include/nspr/prio.h:206:
warning: no semicolon at end of struct or union
/home/qxu/4.0_SP2/uk_dbl/thirdpty/ldap/1.3b/ldap/include/nspr/prio.h:206: parse
error before "static"
/home/qxu/4.0_SP2/uk_dbl/thirdpty/ldap/1.3b/ldap/include/nspr/prio.h:249: field
`mcaddr' has incomplete type
/home/qxu/4.0_SP2/uk_dbl/thirdpty/ldap/1.3b/ldap/include/nspr/prio.h:250: field
`ifaddr' has incomplete type
/home/qxu/4.0_SP2/uk_dbl/thirdpty/ldap/1.3b/ldap/include/nspr/prio.h:251:
confused by earlier errors, bailing out
/* aba_ldap_interface.c, correct version */
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <sys/utsname.h>
#include <sys/time.h>
#include <pthread.h>
#include "ldap.h"
#include "ldappr.h" //xq
#include "cfgAttr.h"
...
===========================================================
cfgAttr.h is our own header, while ldap.h and ldappr.h are headers of MozLDAP.
It seems any header of our own will make the compiling unsuccessful.
prldap_init() is declared in ldappr.h, which in turn includes nspr.h and prio.h.
===========================================================
/* ldappr.h */
#ifndef LDAP_PR_H
#define LDAP_PR_H
#include "nspr.h"
/*
* ldappr.h - prototypes for functions that tie libldap into NSPR (Netscape
* Portable Runtime).
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Function: prldap_init().
*
* Create a new LDAP session handle, but with NSPR I/O, threading, and DNS
* functions installed.
*
* Pass a non-zero value for the 'shared' parameter if you plan to use
* this LDAP * handle from more than one thread.
*
* Returns an LDAP session handle (or NULL if an error occurs).
*/
LDAP * LDAP_CALL prldap_init( const char *defhost, int defport, int shared );
...
/* nspr.h */
#ifndef nspr_h___
#define nspr_h___
...
#include "prio.h"
...
/* prio.h */
#ifndef prio_h___
#define prio_h___
#include "prlong.h"
#include "prtime.h"
#include "prinrval.h"
#include "prinet.h"
...
union PRNetAddr {
struct {
PRUint16 family; /* address family (0x00ff maskable) */
#ifdef XP_BEOS
char data[10]; /* Be has a smaller structure */
#else
char data[14]; /* raw address data */
#endif
} raw;
struct {
PRUint16 family; /* address family (AF_INET) */
PRUint16 port; /* port number */
PRUint32 ip; /* The actual 32 bits of address */
#ifdef XP_BEOS
char pad[4]; /* Be has a smaller structure */
#else
char pad[8];
#endif
} inet;
struct {
PRUint16 family; /* address family (AF_INET6) */
PRUint16 port; /* port number */
PRUint32 flowinfo; /* routing information */
PRIPv6Addr ip; /* the actual 128 bits of address */
PRUint32 scope_id; /* set of interfaces for a scope */
} ipv6;
#if defined(XP_UNIX) || defined(XP_OS2)
struct { /* Unix domain socket address */
PRUint16 family; /* address family (AF_UNIX) */
#ifdef XP_OS2
char path[108]; /* null-terminated pathname */
/* bind fails if size is not 108. */
#else
char path[104]; /* null-terminated pathname */
#endif
} local; //Line 206
#endif
};
...
typedef struct PRMcastRequest {
PRNetAddr mcaddr; /* IP multicast address of
group */ //Line 249
PRNetAddr ifaddr; /* local IP address of
interface */ //Line 250
} PRMcastRequest;
===========================================================
The compiling errors suggested it can't recognize the data structure PRNetAddr
in Line 206 of prio.h. However, I can't see there is anything wrong with these
headers. Just unable to understand why ldappr.h must be included immediately
after system header. Any help?
Thanks,
Xu Qiang
_______________________________________________
dev-tech-ldap mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-ldap