Search code examples
cunixcompilationhp-ux

Compilation error in C: Inconsistent type declaration/Illegal redeclaration for identifier


I am getting the following error while compiling my source code:

Compiling lib/netapi/joindomain.c
cc: "include/smb_ldap.h", line 33: error 1584: Inconsistent type declaration: "ber_tag_t".
cc: "include/smb_ldap.h", line 34: error 1713: Illegal redeclaration for identifier "ber_int_t".
The following command failed:
)
*** Error exit code 1

The corresponding code which flags the error is:

if HAVE_LBER_H
#include <lber.h>
#if defined(HPUX) && !defined(_LBER_TYPES_H)
#ifndef ber_tag_t
typedef unsigned long ber_tag_t;
typedef int ber_int_t;
#endif
#endif 

I request help in understanding the root cause of this error.

Thanks in advance.

Here are my machine and compiler details for reference:

$  uname -a
HP-UX cifsvade B.11.31 U 9000/800 3751280844 unlimited-user license
$  which cc
/usr/bin/cc
$  ls -lrt /usr/bin/cc
lrwxr-xr-x   1 root       sys             17 Oct  8 17:45 /usr/bin/cc -> /opt/ansic/bin/cc
$ 

Solution

  • lber.h defines ber_tag_t and ber_tag_t as follow:

        typedef impl_tag_t ber_tag_t;
        typedef impl_int_t ber_int_t;
    

    In your code you try to redefine them, this is the case. A condition

        #ifndef ber_tag_t
    

    is always true unless you defined ber_tag_t somewhere like

        #define ber_tag_t smth