bug-gnulib
[Top][All Lists]
Advanced

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

Documentation module lib-symbol-visibility


From: Дилян Палаузов
Subject: Documentation module lib-symbol-visibility
Date: Fri, 20 Jul 2012 13:56:39 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0

Hello,

the documentation of the module lib-symbo-visibility, http://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html, recommends defining macro LIBFOO_DLL_EXPORTED, which shall be enabled in all public header files, and annotating all variable, function and class declarations in all public header files of the library with LIBFOO_DLL_EXPORTED.

I would instead leave the public header files as they are, and annotate instead all the variable, function and class definitions (not declarations) with LIBFOO_DLL_EXPORTED. This leads to public header files, which do not mention LIBFOO_DLL_EXPORTED, and are thus smaller and easier to read. My preference is to put in configure.ac

gl_VISIBILITY
AH_BOTTOM([#if HAVE_VISIBILITY
#define EXPORTED __attribute__((__visibility__("default")))
#define HIDDEN   __attribute__((__visibility__("hidden")))
#else
#define EXPORTED
#define HIDDEN
#endif])

which leads to defining properly EXPORTED and HIDDEN in config.h and all .c files #including config.h can make effective use of the EXPORTED/HIDDEN annotations.

Defining LIBFOO_DLL_EXPORTED in public header files has no added value from the user's perspective: mentioning a function in the public header files implies, that the function is visible. As suggested, there is another way to achieve the same result, without touching the header files.

Със здраве
  Дилян

Attachment: dilyan_palauzov.vcf
Description: Vcard


reply via email to

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