aboutsummaryrefslogtreecommitdiff
path: root/lib/cpluff/doc/reference/c-api/group__symbolVisibility.html
blob: b3c2941fc26fd249a1fd8bc1f177601026947666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>C-Pluff C API: Symbol visibility</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.1 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul></div>
<h1>Symbol visibility<br>
<small>
[<a class="el" href="group__cDefines.html">Defines</a>]</small>
</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
Macros for controlling inter-module symbol visibility and linkage. 
<p>
These macros have platform specific values. <a class="el" href="group__symbolVisibility.html#ga2e3768d73167e12c2330e4b96bcbd70">CP_EXPORT</a>, <a class="el" href="group__symbolVisibility.html#gb44eb8224723b45a1c909177bdd7bc32">CP_IMPORT</a> and <a class="el" href="group__symbolVisibility.html#gf58571664980e1a0d2b0bee413296492">CP_HIDDEN</a> can be reused by plug-in implementations for better portability. The complexity is mostly due to Windows DLL exports and imports.<p>
<a class="anchor" name="symbolVisibilityExample"></a> Each module should usually define its own macro to declare API symbols with <a class="el" href="group__symbolVisibility.html#ga2e3768d73167e12c2330e4b96bcbd70">CP_EXPORT</a> and <a class="el" href="group__symbolVisibility.html#gb44eb8224723b45a1c909177bdd7bc32">CP_IMPORT</a> as necessary. For example, a mobule could define a macro <code>MY_API</code> in the API header file as follows.<p>
<div class="fragment"><pre class="fragment"><span class="preprocessor"> #ifndef MY_API</span>
<span class="preprocessor"></span><span class="preprocessor"> #  define MY_API CP_IMPORT</span>
<span class="preprocessor"> #endif</span>
</pre></div><p>
By default the API symbols would then be marked for import which is correct when client modules are including the API header file. When compiling the module itself the option <code>-DMY_API=CP_EXPORT</code> would be passed to the compiler to override the API header file and to mark the API symbols for export. The overriding definition could also be included in module source files or in an internal header file before including the API header file. 
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__symbolVisibility.html#ga2e3768d73167e12c2330e4b96bcbd70">CP_EXPORT</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declares a symbol to be exported for inter-module usage.  <a href="#ga2e3768d73167e12c2330e4b96bcbd70"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__symbolVisibility.html#gb44eb8224723b45a1c909177bdd7bc32">CP_IMPORT</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declares a symbol to be imported from another module.  <a href="#gb44eb8224723b45a1c909177bdd7bc32"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__symbolVisibility.html#gf58571664980e1a0d2b0bee413296492">CP_HIDDEN</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declares a symbol hidden from other modules.  <a href="#gf58571664980e1a0d2b0bee413296492"></a><br></td></tr>
</table>
<hr><h2>Define Documentation</h2>
<a class="anchor" name="ga2e3768d73167e12c2330e4b96bcbd70"></a><!-- doxytag: member="cpluffdef.h::CP_EXPORT" ref="ga2e3768d73167e12c2330e4b96bcbd70" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CP_EXPORT          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Declares a symbol to be exported for inter-module usage. 
<p>
When compiling the module which defines the symbol this macro should be placed at the start of the symbol declaration to ensure that the symbol is exported to other modules. However, when compiling other modules the declaration of the symbol should start with <a class="el" href="group__symbolVisibility.html#gb44eb8224723b45a1c909177bdd7bc32">CP_IMPORT</a>. See <a class="el" href="group__symbolVisibility.html#symbolVisibilityExample">the example</a> of how to do this. 
</div>
</div><p>
<a class="anchor" name="gb44eb8224723b45a1c909177bdd7bc32"></a><!-- doxytag: member="cpluffdef.h::CP_IMPORT" ref="gb44eb8224723b45a1c909177bdd7bc32" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CP_IMPORT          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Declares a symbol to be imported from another module. 
<p>
When compiling a module which uses the symbol this macro should be placed at the start of the symbol declaration to ensure that the symbol is imported from the defining module. However, when compiling the defining module the declaration of the symbol should start with <a class="el" href="group__symbolVisibility.html#ga2e3768d73167e12c2330e4b96bcbd70">CP_EXPORT</a>. See <a class="el" href="group__symbolVisibility.html#symbolVisibilityExample">the example</a> of how to do this. 
</div>
</div><p>
<a class="anchor" name="gf58571664980e1a0d2b0bee413296492"></a><!-- doxytag: member="cpluffdef.h::CP_HIDDEN" ref="gf58571664980e1a0d2b0bee413296492" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CP_HIDDEN          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Declares a symbol hidden from other modules. 
<p>
This macro should be placed at the start of the symbol declaration to hide the symbol from other modules (if supported by the platform). This macro is not intended to be used with symbols declared as "static" which are already internal to the object file. Some platforms do not support hiding of symbols and therefore unique prefixes should be used for global symbols internal to the module even when they are declared using this macro. 
</div>
</div><p>
<hr size="1">
<p class="footer">
<a href="http://www.c-pluff.org/">C-Pluff</a>, a plug-in framework for C<br>
Copyright 2007 <a href="http://www.jlehtinen.net/">Johannes Lehtinen</a>
</p>
<p class="generated-by">
Generated on Fri Apr 6 15:40:55 2007 for C-Pluff C API by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1
</p>
</body>
</html>