Declarator for inline and undeclared identifier messages
When researching a difference between the current versions of libarchive on AIX and trying to figure out why the libarchive.so
wasn’t being symlinked to what was being built, I got the following compilation error on the release package for v3.4.3:
"libarchive/archive_endian.h", line 158.8: 1506-485 (S) Parameter declaration list is incompatible with declarator for inline.
"libarchive/archive_endian.h", line 170.45: 1506-045 (S) Undeclared identifier pp.
"libarchive/archive_endian.h", line 172.16: 1506-045 (S) Undeclared identifier u.
"libarchive/archive_endian.h", line 178.1: 1506-277 (S) Syntax error: possible missing ';' or ','?
Undeclared identifier? It’s right there!
The “undeclared identifier” messages are confusing, because, at first glance, it appears that the identifier is defined in the parameter list.
static inline void
archive_be64enc(void *pp, uint64_t u)
{
unsigned char *p = (unsigned char *)pp;
archive_be32enc(p, (uint32_t)(u >> 32));
archive_be32enc(p + 4, (uint32_t)(u & 0xffffffff));
}
IBM forum result didn’t seem all that helpful
Searching for what might actually lead to the the error “Parameter declaration list is incompatible with declarator for inline” led to XLC complains CCN3277, CCN3485, CCN3045 but gcc on z/Linux does not complain with the seemingly unhelpful response, “Then what gcc (or MS, for that matter) does is irrelevant. You have to take these errors one at a time and resolve them.”

Wait… inline
is… C++
?
inline
is a keyword in C++, not C, but gcc
supports inline
as well, leading to a departure from the C89 standard. Curiously, v3.6.2 of libarchive
fixes this error, so all I needed to do is figure out how they’re compiling differently (I hoped).
Diff all the things!
I downloaded the v3.4.3 and v3.6.2 releases of libarchive
and ran the ./configure
script for both of them, and then did a diff
on the generated Makefile
and libtool
. Doing so showed that v3.4.3 was using cc -qlanglvl=extc89
to invoke the C compiler while v3.6.2 was using cc -qlanglvl=extc1x
… extc1x
pointing to a 201x C standard instead of C89 for the AIX xLC
compiler.
Solution
The solution was to replace all occurrences of extc89
with extc1x
to get past this error. Makefile
and libtool
had two lines each in my case. The undeclared identifier error is a result of the misinterpretation of the inline
syntax. Once I resolved the inline
issue, the C function header was interpreted correctly.
pthread error
Working with open source projects on AIX is challenging due many factors, including lack of access to development environments for AIX, semi-closed forums, and lack of open documentation stemming from the closed and proprietary environments. I still have a subsequent error to deal with my build of libarchive
:
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
The above .pthread_mutex
errors can be resolved by making sure -lpthread
is in the LIBS
variable for the generated Makefile, which is ultimately sources from build/pkgconfig/libarchive.pc
in the case of libarchive
More to come
Building the last version of libarchive (3.4.0) that worked for a release on AIX results in a new error: 1506-285 (S) The indirection operator cannot be applied to a pointer to an incomplete struct or union
. This will be my next build error to tackle, or at least see why this version is specifically