1
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
5
<title>Exporting a C API</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
7
<link rel="start" href="index.html" title="GObject Reference Manual">
6
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
7
<link rel="home" href="index.html" title="GObject Reference Manual">
8
8
<link rel="up" href="chapter-intro.html" title="Background">
9
9
<link rel="prev" href="chapter-intro.html" title="Background">
10
10
<link rel="next" href="chapter-gtype.html" title="The GLib Dynamic Type System">
11
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
11
<meta name="generator" content="GTK-Doc V1.11 (XML mode)">
12
12
<link rel="stylesheet" href="style.css" type="text/css">
13
13
<link rel="preface" href="pr01.html" title="Introduction">
14
<link rel="part" href="pt01.html" title="Part I. Concepts">
14
<link rel="part" href="pt01.html" title="Part I. Concepts">
15
15
<link rel="chapter" href="chapter-intro.html" title="Background">
16
16
<link rel="chapter" href="chapter-gtype.html" title="The GLib Dynamic Type System">
17
17
<link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
18
18
<link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
19
19
<link rel="reference" href="rn01.html" title="API Reference">
20
20
<link rel="reference" href="rn02.html" title="Tools Reference">
21
<link rel="part" href="pt02.html" title="Part IV. Tutorial">
21
<link rel="part" href="pt02.html" title="Part IV. Tutorial">
22
22
<link rel="chapter" href="howto-gobject.html" title="How to define and implement a new GObject">
23
23
<link rel="chapter" href="howto-interface.html" title="How to define and implement interfaces">
24
24
<link rel="chapter" href="howto-signals.html" title="How to create and use signals">
25
<link rel="part" href="pt03.html" title="Part V. Related Tools">
25
<link rel="part" href="pt03.html" title="Part V. Related Tools">
26
<link rel="chapter" href="tools-vala.html" title="Vala">
26
27
<link rel="chapter" href="tools-gob.html" title="GObject builder">
27
28
<link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of GObjects">
28
29
<link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
36
37
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
37
38
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
38
39
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
40
<link rel="index" href="ix10.html" title="Index of new symbols in 2.14">
40
42
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
41
43
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
48
50
<div class="sect1" lang="en">
49
51
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
50
<a name="id2763033"></a>Exporting a C API</h2></div></div></div>
52
<a name="id2960730"></a>Exporting a C API</h2></div></div></div>
52
54
C APIs are defined by a set of functions and global variables which are usually exported from a
53
55
binary. C functions have an arbitrary number of arguments and one return value. Each function is thus
117
119
reads the original function signature.</p></li>
118
120
<li><p>The solution used by GLib is to use the GType library which holds at runtime a description of
119
121
all the objects manipulated by the programmer. This so-called <span class="emphasis"><em>dynamic type</em></span>
120
<sup>[<a name="id2761671" href="#ftn.id2761671" class="footnote">1</a>]</sup>
122
<sup>[<a name="id2959595" href="#ftn.id2959595" class="footnote">1</a>]</sup>
121
123
library is then used by special generic glue code to automatically convert function parameters and
122
124
function calling conventions between different runtime domains.</p></li>
126
128
boundaries is written once: the figure below states this more clearly.
128
130
<div class="figure">
129
<a name="id2761698"></a><p class="title"><b>Figure 1. </b></p>
131
<a name="id2959621"></a><p class="title"><b>Figure 1. </b></p>
130
132
<div class="figure-contents"><div class="mediaobject" align="center"><img src="glue.png" align="middle"></div></div>
132
134
<p><br class="figure-break">
145
147
<div class="footnotes">
146
148
<br><hr width="100" align="left">
147
<div class="footnote"><p><sup>[<a name="ftn.id2761671" href="#id2761671" class="para">1</a>] </sup>
149
<div class="footnote"><p><sup>[<a name="ftn.id2959595" href="#id2959595" class="para">1</a>] </sup>
148
150
There are numerous different implementations of dynamic type systems: all C++
149
151
compilers have one, Java and .NET have one too. A dynamic type system allows you
150
152
to get information about every instantiated object at runtime. It can be implemented