The reason for the definition is that it works in tandem with the gcc compiler directive "-fvisibility=hidden" to stop exporting symbols that are not part of the actual API. This second piece of the puzzle is provided in the CMakeLists.txt files.
Using empty macros as you suggest should "work", at the expense of symbol bloat. But you may wish to use any features of your compiler chain that achieves a similar result (it might be specified some other way). Note that the Windows macro works differently and does not require a cooperative compiler option via CMake. On Wednesday, 5 October 2016, Adel Boutros <adelbout...@live.com> wrote: > Hello, > > > We are trying to compile Proton on Solaris. We have stumbled upon the > usage of macro (__attribute__) which is only available in GCC and not on > SunStudio. > > > In proton-c/bindings/cpp/include/proton/internal/export.hpp: > > # define PN_CPP_EXPORT __attribute ((visibility ("default"))) > > > Checking GCC definition of "__attribute " and "visibility", it seems that > default visibility does nothing because it is the default behavior. > > > Is there a reason for this definition? If not, can we safely define > PN_CPP_EXPORT and PN_CPP_CLASS_IMPORT to empty macro in that case in the > "#else" part? > > > https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Function-Attributes.html > > > visibility ("visibility_type") > This attribute affects the linkage of the declaration to which it is > attached. There are four supported visibility_type values: default, hidden, > protected or internal visibility. > > void __attribute__ ((visibility ("protected"))) > f () { /* Do something. */; } > int i __attribute__ ((visibility ("hidden"))); > > > The possible values of visibility_type correspond to the visibility > settings in the ELF gABI. > > default > Default visibility is the normal case for the object file format. This > value is available for the visibility attribute to override other options > that may change the assumed visibility of entities. > > On ELF, default visibility means that the declaration is visible to other > modules and, in shared libraries, means that the declared entity may be > overridden. > > On Darwin, default visibility means that the declaration is visible to > other modules. > > Default visibility corresponds to "external linkage" in the language. > > Function Attributes - Using the GNU Compiler Collection (GCC)< > https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Function-Attributes.html> > gcc.gnu.org > 6.30 Declaring Attributes of Functions. In GNU C, you declare certain > things about functions called in your program which help the compiler > optimize function calls ... > > > > > > Regards, > > Adel > >