bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inline.m4: use compiler, not cpp


From: Eric Blake
Subject: Re: inline.m4: use compiler, not cpp
Date: Sat, 11 Nov 2006 06:28:05 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Thunderbird/1.5.0.8 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Jim Meyering on 11/10/2006 4:14 AM:
> 
> Without -O, gcc *does* define __NO_INLINE__, so HAVE_INLINE was not
> defined.  However, when compiling (with $CFLAGS containing -O), there
> was no external definition of any function like xnmalloc or xcharalloc.

I noticed that even when I configure with CFLAGS=-fno-inline, that
config.h leaves HAVE_INLINE undefined, but does not bother to #define
inline to the empty string.  Therefore my unprotected use of inline in
M4's m4.h still silently resulted in multiple copies of a function:

$ grep -B3 to_uchar src/m4.h
/* Convert a possibly-signed character to an unsigned character.  This is
   a bit safer than casting to unsigned char, since it catches some type
   errors that the cast doesn't.  */
static inline unsigned char to_uchar (char ch) { return ch; }
$ nm src/m4 | grep to_uchar
004071c7 t _to_uchar
0040a3e8 t _to_uchar
00401da2 t _to_uchar
0040ba4c t _to_uchar
00408b2e t _to_uchar

What I should have done, of course, is:
#if HAVE_INLINE
static inline unsigned char to_uchar (char ch) { return ch; }
#else
# define to_uchar(C) ((unsigned char) (C))
#endif

Is it worth trying to override AC_C_INLINE's definition of inline when we
detect that inline is not supported, such that inline is redefined to the
empty string, and uses of inline in headers that are not protected by
HAVE_INLINE will then cause multiple copy link errors if used in more than
one file?  Or perhaps reorder m4/inline.m4 to check for __NO_INLINE__
first, and only invoke AC_C_INLINE if __NO_INLINE__ is undefined?

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFVc/l84KuGfSFAYARAm7gAJ4uFjcP70XWdzORoohyMZnXP7ptmACfbMEp
kGT4kQ+JpsIQl/bwKko6cPs=
=e3FF
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]