inline problem

Joseph Bruni brunij@earthlink.net
Mon Feb 10 05:47:01 2003


>> autoconf defines inline in config.h, and all of the intl/ files seem
>> to include that before including gettextP.h.  Can you tell me which .c
>> file is breaking?  Also, what does config.h show for "inline"?
>>
>> David
>>


David,

I figured it out. It turns out to be a bug in HP's C compiler. 
Following are the details of my discovery.

First, when I ran configure, the only option I gave it was 
--prefix=/opt/gnu.

Make then dies on the first file, ./intl/intl-compat.c. Below is the 
transcript from "make".
=========
Making all in intl
         cc -c -DLOCALEDIR=\"/opt/gnu/share/locale\" 
-DLOCALE_ALIAS_PATH=\"/opt/gnu/share/locale\"  
-DLIBDIR=\"/opt/gnu/lib\" -DHAVE_CONFIG_H -I.. -I. -I../intl  -g -Ae 
-D_HPUX_SOURCE  intl-compat.c
cc: "gettextP.h", line 67: error 1000: Unexpected symbol: "SWAP".
cc: panic 2017: Cannot recover from earlier errors, terminating.
*** Error exit code 1
=========

Searching through config.h for references to "inline" turns up the 
following:

=========
/* Define as `__inline' if that's what the C compiler calls it, or to 
nothing
    if it is not supported. */
/* #undef inline */
=========

Nothing more.

Looking through config.log shows this:

=========
configure:5264: checking for inline
configure:5281: cc -c -g -Ae -D_HPUX_SOURCE  conftest.c >&5
configure:5284: $? = 0
configure:5287: test -s conftest.o
configure:5290: $? = 0
configure:5301: result: inline
...
configure:8008: checking for inline
configure:8045: result: inline
...
ac_cv_c_inline=inline
=========

I then boiled this down to a test case to find out why autoconf senses 
a working "inline" keyword, but having it die when you try to use it. 
Suppose you try to compile this:

static inline unsigned foo(unsigned bar)
{
	return bar;
}

This will compile just fine. However, if you try to compile this:

typedef unsigned UINT;
static inline UINT foo(UINT bar)
{
	return bar;
}

You get this:
cc: "bozo.c", line 2: error 1000: Unexpected symbol: "foo".
cc: panic 2017: Cannot recover from earlier errors, terminating.

If you remove the "inline" keyword, it compiles just fine. So, we have 
a choice. We can either remove the inline keyword, or remove the 
typedef. I tell you, there is nothing I hate worse than bugs in one's 
tools. I'll need to report this to HP. In the meantime, perhaps some of 
the GnuPG programmers can add a work-around for HP's broken compiler. ;)

Joe