inline problem

David Shaw dshaw@jabberwocky.com
Tue Feb 11 01:41:24 2003


On Sun, Feb 09, 2003 at 09:48:04PM -0700, Joseph Bruni wrote:

> 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. ;)

Good catch there.  I think it would be good to report this to the
autoconf people (cc'd).  They can then improve the "inline" testing
code to catch this case, and all autoconfed software can benefit.

For the autoconf folks: GnuPG uses autoconf 2.54.

David

-- 
   David Shaw  |  dshaw@jabberwocky.com  |  WWW http://www.jabberwocky.com/
+---------------------------------------------------------------------------+
   "There are two major products that come out of Berkeley: LSD and UNIX.
      We don't believe this to be a coincidence." - Jeremy S. Anderson