1 /*-------------------------------------------------------------------------
2 * C-Pluff, a plug-in framework for C
3 * Copyright 2007 Johannes Lehtinen
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *-----------------------------------------------------------------------*/
25 * Common defines shared by C-Pluff C and C++ APIs.
26 * This file is automatically included by the top level C and C++
27 * API header files. There should be no need to include it explicitly.
34 /* ------------------------------------------------------------------------
36 * ----------------------------------------------------------------------*/
39 * @defgroup versionInfo Version information
40 * @ingroup cDefines cxxDefines
42 * C-Pluff version information. Notice that this version information
43 * is static version information included in header files. The
44 * macros introduced here can be used for compile time checks.
49 * The C-Pluff release version string. This string identifies a specific
50 * version of the C-Pluff distribution. Compile time software compatibility
51 * checks should use #CP_VERSION_MAJOR and #CP_VERSION_MINOR instead.
53 #define CP_VERSION "0.1.3"
56 * The major version number component of the release version. This is an
59 #define CP_VERSION_MAJOR 0
62 * The minor version number component of the release version. This is an
65 #define CP_VERSION_MINOR 1
70 /* ------------------------------------------------------------------------
72 * ----------------------------------------------------------------------*/
75 * @defgroup symbolVisibility Symbol visibility
76 * @ingroup cDefines cxxDefines
78 * Macros for controlling inter-module symbol visibility and linkage. These
79 * macros have platform specific values. #CP_EXPORT, #CP_IMPORT and #CP_HIDDEN
80 * can be reused by plug-in implementations for better portability. The
81 * complexity is mostly due to Windows DLL exports and imports.
83 * @anchor symbolVisibilityExample
84 * Each module should usually define its own macro to declare API symbols with
85 * #CP_EXPORT and #CP_IMPORT as necessary. For example, a mobule could define
86 * a macro @c MY_API in the API header file as follows.
90 * # define MY_API CP_IMPORT
94 * By default the API symbols would then be marked for import which is correct
95 * when client modules are including the API header file. When compiling the
96 * module itself the option @c -DMY_API=CP_EXPORT would be passed to the compiler to
97 * override the API header file and to mark the API symbols for export.
98 * The overriding definition could also be included in module source files or
99 * in an internal header file before including the API header file.
106 * Declares a symbol to be exported for inter-module usage. When compiling the
107 * module which defines the symbol this macro should be placed
108 * at the start of the symbol declaration to ensure that the symbol is exported
109 * to other modules. However, when compiling other modules the declaration of
110 * the symbol should start with #CP_IMPORT.
111 * See @ref symbolVisibilityExample "the example" of how to do this.
117 * Declares a symbol to be imported from another module. When compiling a
118 * module which uses the symbol this macro should be placed at the start of
119 * the symbol declaration to ensure that the symbol is imported from the
120 * defining module. However, when compiling the defining module the declaration
121 * of the symbol should start with #CP_EXPORT.
122 * See @ref symbolVisibilityExample "the example" of how to do this.
128 * Declares a symbol hidden from other modules. This macro should be
129 * placed at the start of the symbol declaration to hide the symbol from other
130 * modules (if supported by the platform). This macro is not intended to be
131 * used with symbols declared as "static" which are already internal to the
132 * object file. Some platforms do not support hiding of symbols and therefore
133 * unique prefixes should be used for global symbols internal to the module
134 * even when they are declared using this macro.
138 # define CP_EXPORT __declspec(dllexport)
139 # define CP_IMPORT extern __declspec(dllimport)
141 #elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
143 # define CP_IMPORT extern
144 # define CP_HIDDEN __attribute__ ((visibility ("hidden")))
147 # define CP_IMPORT extern
154 /* ------------------------------------------------------------------------
156 * ----------------------------------------------------------------------*/
159 * @defgroup cDefinesGCCAttributes GCC attributes
160 * @ingroup cDefines cxxDefines
162 * These macros conditionally define GCC attributes for declarations.
163 * They are used in C-Pluff API declarations to enable better optimization
164 * and error checking when using GCC. In non-GCC platforms they have
172 * Declares a function as pure function having no side effects.
173 * This attribute is supported in GCC since version 2.96.
174 * Such functions can be subject to common subexpression elimination
175 * and loop optimization.
179 * @def CP_GCC_NONNULL
181 * Specifies that some pointer arguments to a function should have
182 * non-NULL values. Takes a variable length list of argument indexes as
183 * arguments. This attribute is supported in GCC since version 3.3.
184 * It can be used for enhanced error checking and some optimizations.
187 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
188 #define CP_GCC_PURE __attribute__((pure))
192 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
193 #define CP_GCC_NONNULL(...) __attribute__((nonnull (__VA_ARGS__)))
195 #define CP_GCC_NONNULL(...)
200 #endif /*CPLUFFDEF_H_*/