[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
automake conditional for visibility?
From: |
Simon Josefsson |
Subject: |
automake conditional for visibility? |
Date: |
Tue, 03 Mar 2009 14:09:36 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.90 (gnu/linux) |
Bruno, this part of the documentation for the "visibility" module
appears to assume that all public header files are generated from *.in
files via autoconf:
Add a C macro definition, say @samp{-DBUILDING_LIBFOO}, to the CPPFLAGS
for the compilation of the sources that make up the library.
Define a macro specific to your library like this.
@smallexample
#if @@HAVE_VISIBILITY@@ && BUILDING_LIBFOO
#define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
#else
#define LIBFOO_DLL_EXPORTED
#endif
@end smallexample
This macro should be enabled in all public header files of your library.
How about adding a automake conditional? That would allow adding the
-DBUILDING_LIBFOO only when visibility is supported, like this:
if HAVE_VISIBILITY
AM_CPPFLAGS += -DBUILDING_LIBFOO
endif
And have the public header file contain:
#if BUILDING_LIBFOO
#define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default")))
#else
#define LIBFOO_DLL_EXPORTED
#endif
Btw, to encourage namespace clean header files, I would prefer
LIBFOO_BUILDING.
However, possibly the name of the CPP symbol used by the manual could be
modified to reflect that it also checks whether visibility is supported.
How about LIBFOO_ADD_VISIBILITY?
/Simon
diff --git a/m4/visibility.m4 b/m4/visibility.m4
index 70bca56..7b083b9 100644
--- a/m4/visibility.m4
+++ b/m4/visibility.m4
@@ -1,5 +1,5 @@
# visibility.m4 serial 2 (gettext-0.18)
-dnl Copyright (C) 2005, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -49,4 +49,5 @@ AC_DEFUN([gl_VISIBILITY],
AC_SUBST([HAVE_VISIBILITY])
AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
[Define to 1 or 0, depending whether the compiler supports simple
visibility declarations.])
+ AM_CONDITIONAL(HAVE_VISIBILITY, test "$HAVE_VISIBILITY" = "1")
])
- automake conditional for visibility?,
Simon Josefsson <=
- Re: automake conditional for visibility?, Bruno Haible, 2009/03/03
- Re: automake conditional for visibility?, Simon Josefsson, 2009/03/03
- Re: automake conditional for visibility?, Simon Josefsson, 2009/03/03
- Re: automake conditional for visibility?, Bruno Haible, 2009/03/03
- Re: automake conditional for visibility?, Simon Josefsson, 2009/03/04
- Re: automake conditional for visibility?, Bruno Haible, 2009/03/04
- Re: automake conditional for visibility?, Simon Josefsson, 2009/03/04