| 1 |
/* |
| 2 |
* |
| 3 |
* GeanyGenDoc, a Geany plugin to ease generation of source code documentation |
| 4 |
* Copyright (C) 2010-2011 Colomban Wendling <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software: you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation, either version 3 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef H_GGD_MACROS |
| 22 |
#define H_GGD_MACROS |
| 23 |
|
| 24 |
|
| 25 |
#if defined (__GNUC__) && \ |
| 26 |
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
| 27 |
# define __GGD_DO_PRAGMA(s) _Pragma (#s) |
| 28 |
/** |
| 29 |
* GGD_PUSH_VISIBILITY: |
| 30 |
* @v: The visibility to push (one of default, hidden, internal or protected) |
| 31 |
* |
| 32 |
* Pushes a visibility, applying to the following symbols until the next |
| 33 |
* GGD_POP_VISIBILITY(). |
| 34 |
* You must have a corresponding GGD_POP_VISIBILITY() to each |
| 35 |
* GGD_PUSH_VISIBILITY(). |
| 36 |
*/ |
| 37 |
# define GGD_PUSH_VISIBILITY(v) __GGD_DO_PRAGMA (GCC visibility push(v)) |
| 38 |
/** |
| 39 |
* GGD_POP_VISIBILITY: |
| 40 |
* |
| 41 |
* Pops the latest visibility pushed by GGD_PUSH_VISIBILITY(). |
| 42 |
*/ |
| 43 |
# define GGD_POP_VISIBILITY() __GGD_DO_PRAGMA (GCC visibility pop) |
| 44 |
#else /* ! GNUC >= 4.2 */ |
| 45 |
# define GGD_PUSH_VISIBILITY(v) /* nothing */ |
| 46 |
# define GGD_POP_VISIBILITY() /* nothing */ |
| 47 |
#endif /* GNUC >= 4.2 */ |
| 48 |
|
| 49 |
/** |
| 50 |
* GGD_BEGIN_PLUGIN_API: |
| 51 |
* |
| 52 |
* Marks the beginning of some plugin API definitions. |
| 53 |
* In practice, this makes the symbols have the internal visibility -- not to |
| 54 |
* pollute the symbol table of the built plugin for example. |
| 55 |
* You must add a corresponding %GGD_END_PLUGIN_API to end the declarations. |
| 56 |
* |
| 57 |
* <warning><para> |
| 58 |
* You must not include anything that must be accessible from outside the plugin |
| 59 |
* between %GGD_BEGIN_PLUGIN_API and %GGD_END_PLUGIN_API. Doing so would lead to |
| 60 |
* strange crashes since the symbols are not exported at all. An example are the |
| 61 |
* Geany's variables such as geany_functions, since Geany will need to access it |
| 62 |
* at runtime. |
| 63 |
* </para></warning> |
| 64 |
* |
| 65 |
* <example> |
| 66 |
* <title>Defining some plugin API</title> |
| 67 |
* <programlisting> |
| 68 |
* #include <glib.h> |
| 69 |
* |
| 70 |
* #include "ggd-macros.h" |
| 71 |
* |
| 72 |
* G_BEGIN_DECLS |
| 73 |
* GGD_BEGIN_PLUGIN_API |
| 74 |
* |
| 75 |
* gint ggd_wonderful_function (void); |
| 76 |
* |
| 77 |
* GGD_END_PLUGIN_API |
| 78 |
* G_END_DECLS |
| 79 |
* </programlisting> |
| 80 |
* </example> |
| 81 |
*/ |
| 82 |
#define GGD_BEGIN_PLUGIN_API GGD_PUSH_VISIBILITY (internal) |
| 83 |
/** |
| 84 |
* GGD_END_PLUGIN_API: |
| 85 |
* |
| 86 |
* Marks the end of some plugin API definitions. See %GGD_BEGIN_PLUGIN_API. |
| 87 |
*/ |
| 88 |
#define GGD_END_PLUGIN_API GGD_POP_VISIBILITY () |
| 89 |
|
| 90 |
|
| 91 |
#endif /* guard */ |