menu: added new Keywords tag to .desktop files
[barry.git] / src / dll.h
bloba1ed5a5220138b375407ed6448f524c61d5e49f1
1 ///
2 /// \file dll.h
3 /// Macros for handling DLL/library API visibility
4 ///
5 /// Based on documentation at: http://gcc.gnu.org/wiki/Visibility
6 ///
8 /*
9 Copyright (C) 2005-2013, Net Direct Inc. (http://www.netdirect.ca/)
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 See the GNU General Public License in the COPYING file at the
21 root directory of this project for more details.
24 #ifndef __BARRY_DLL_H__
25 #define __BARRY_DLL_H__
29 // Every non-templated class that is meant to be used by an application
30 // must be declared as:
32 // class BXEXPORT ClassName {};
34 // Every private (not protected or public) member function of an exported
35 // class can be declared as:
37 // private:
38 // BXLOCAL void HelperFunc();
40 // Every non-templated function that is meant to be used by an application
41 // must be declared as:
43 // BXEXPORT int GetAmount();
44 // BXEXPORT std::ostream& operator<< (std::ostream& os, const Obj &obj);
47 // Everything else will be hidden, as per the build system's configuration.
51 #if __BARRY_HAVE_GCCVISIBILITY__
53 #define BXEXPORT __attribute__ ((visibility("default")))
54 #define BXLOCAL __attribute__ ((visibility("hidden")))
56 #elif defined(WIN32)
58 #ifdef __BARRY_LIBRARY_BUILD__
59 #define BXEXPORT __declspec( dllexport )
60 #define BXLOCAL
61 #else
62 #define BXEXPORT __declspec( dllimport )
63 #define BXLOCAL
64 #endif
66 // Disable "needs to have dll interface warning" which
67 // comes from exporting classes which make use of non-exported
68 // templated classes.
69 #pragma warning(disable: 4251)
71 #else
73 #define BXEXPORT
74 #define BXLOCAL
76 #endif
80 // Add this to the end of variable argument function declarations.
81 // For example:
83 // void log(const char *msg, ...) BARRY_GCC_FORMAT_CHECK(1, 2);
85 // This tells GCC that the first argument is the format string, and
86 // the second is the first variable argument to check.
88 // If you use this inside a class, you need to allow for the invisible
89 // 'this' pointer:
91 // class Trace {
92 // public:
93 // void logf(const char *msg, ...) BARRY_GCC_FORMAT_CHECK(2, 3);
94 // };
96 #if __GNUC__
97 #define BARRY_GCC_FORMAT_CHECK(a,b) __attribute__ ((format(printf, a, b)))
98 #else
99 #define BARRY_GCC_FORMAT_CHECK(a,b)
100 #endif
102 #endif