On 01/22/2011 07:08 PM, Paul Eggert wrote:
> To do this, one way to would be to follow the example of
> 
>    +# gl_ASSERT_NO_GNULIB_POSIXCHECK
>    +# asserts that there will never be a need to #define GNULIB_POSIXCHECK.
>    +# and thereby enables an optimization of configure and config.h.
>    +# Used by Emacs.
>    +AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
>    +[
>    +  dnl Override gl_WARN_ON_USE_PREPARE.
>    +  AC_DEFUN([gl_WARN_ON_USE_PREPARE], [])
>    +])

Yes, this works for me, and I actually would use it in other projects (a
developer can temporarily comment out the line, use the POSIX_CHECK
features, then recomment it so that ordinary users don't pay the penalty
for checking for declarations when they aren't going to use POSIX_CHECK).

> Another possibility would be to remove all the HAVE_RAW_DECL_*
> symbols, and remove gl_WARN_ON_USE_PREPARE entirely, and replace all
> .h code that looks like this:

No.  That would cause compilation failures.

> 
>   #elif defined GNULIB_POSIXCHECK
>   # undef chown
>   # if HAVE_RAW_DECL_CHOWN
>   _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and 
> "
>                  "doesn't treat a uid or gid of -1 on some systems - "
>                  "use gnulib module chown for portability");

_GL_WARN_ON_USE _only_ works if a function is already declared (since it
uses __typeof__(function) to append the gcc warning attribute).  If the
function is not declared, life is fine without needing _GL_WARN_ON_USE
in the first place (the portability issue would have been detected by
the compilation failure when developing on a platform that lacks the
function).  But it is when the function is declared, but the gnulib
version not in use, where you want POSIX_CHECK to issue the warning.

> The above analysis suggest that the latter approach is better.
> I'd appreciate a review of it, along with any further suggestions
> for improvement.

I'm only in favor of the former approach, not the latter.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to