00001 /// 00002 /// \file dll.h 00003 /// Macros for handling DLL/library API visibility 00004 /// 00005 /// Based on documentation at: http://gcc.gnu.org/wiki/Visibility 00006 /// 00007 00008 /* 00009 Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/) 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 This program is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00019 00020 See the GNU General Public License in the COPYING file at the 00021 root directory of this project for more details. 00022 */ 00023 00024 #ifndef __BARRY_DLL_H__ 00025 #define __BARRY_DLL_H__ 00026 00027 // 00028 // 00029 // Every non-templated class that is meant to be used by an application 00030 // must be declared as: 00031 // 00032 // class BXEXPORT ClassName {}; 00033 // 00034 // Every private (not protected or public) member function of an exported 00035 // class can be declared as: 00036 // 00037 // private: 00038 // BXLOCAL void HelperFunc(); 00039 // 00040 // Every non-templated function that is meant to be used by an application 00041 // must be declared as: 00042 // 00043 // BXEXPORT int GetAmount(); 00044 // BXEXPORT std::ostream& operator<< (std::ostream& os, const Obj &obj); 00045 // 00046 // 00047 // Everything else will be hidden, as per the build system's configuration. 00048 // 00049 // 00050 00051 #if __BARRY_HAVE_GCCVISIBILITY__ 00052 00053 #define BXEXPORT __attribute__ ((visibility("default"))) 00054 #define BXLOCAL __attribute__ ((visibility("hidden"))) 00055 00056 #else 00057 00058 #define BXEXPORT 00059 #define BXLOCAL 00060 00061 #endif 00062 00063 00064 // 00065 // Add this to the end of variable argument function declarations. 00066 // For example: 00067 // 00068 // void log(const char *msg, ...) BARRY_GCC_FORMAT_CHECK(1, 2); 00069 // 00070 // This tells GCC that the first argument is the format string, and 00071 // the second is the first variable argument to check. 00072 // 00073 // If you use this inside a class, you need to allow for the invisible 00074 // 'this' pointer: 00075 // 00076 // class Trace { 00077 // public: 00078 // void logf(const char *msg, ...) BARRY_GCC_FORMAT_CHECK(2, 3); 00079 // }; 00080 // 00081 #if __GNUC__ 00082 #define BARRY_GCC_FORMAT_CHECK(a,b) __attribute__ ((format(printf, a, b))) 00083 #else 00084 #define BARRY_GCC_FORMAT_CHECK(a,b) 00085 #endif 00086 00087 #endif 00088