3
<title>Portability functions - GNU Scientific Library -- Reference Manual</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
6
<meta name="generator" content="makeinfo 4.8">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Using-the-library.html#Using-the-library" title="Using the library">
9
<link rel="prev" href="Long-double.html#Long-double" title="Long double">
10
<link rel="next" href="Alternative-optimized-functions.html#Alternative-optimized-functions" title="Alternative optimized functions">
11
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
13
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
15
Permission is granted to copy, distribute and/or modify this document
16
under the terms of the GNU Free Documentation License, Version 1.2 or
17
any later version published by the Free Software Foundation; with the
18
Invariant Sections being ``GNU General Public License'' and ``Free Software
19
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
20
and with the Back-Cover Text being (a) (see below). A copy of the
21
license is included in the section entitled ``GNU Free Documentation
24
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
25
GNU Manual, like GNU software.''-->
26
<meta http-equiv="Content-Style-Type" content="text/css">
27
<style type="text/css"><!--
28
pre.display { font-family:inherit }
29
pre.format { font-family:inherit }
30
pre.smalldisplay { font-family:inherit; font-size:smaller }
31
pre.smallformat { font-family:inherit; font-size:smaller }
32
pre.smallexample { font-size:smaller }
33
pre.smalllisp { font-size:smaller }
34
span.sc { font-variant:small-caps }
35
span.roman { font-family:serif; font-weight:normal; }
36
span.sansserif { font-family:sans-serif; font-weight:normal; }
42
<a name="Portability-functions"></a>
43
Next: <a rel="next" accesskey="n" href="Alternative-optimized-functions.html#Alternative-optimized-functions">Alternative optimized functions</a>,
44
Previous: <a rel="previous" accesskey="p" href="Long-double.html#Long-double">Long double</a>,
45
Up: <a rel="up" accesskey="u" href="Using-the-library.html#Using-the-library">Using the library</a>
49
<h3 class="section">2.7 Portability functions</h3>
51
<p>To help in writing portable applications GSL provides some
52
implementations of functions that are found in other libraries, such as
53
the BSD math library. You can write your application to use the native
54
versions of these functions, and substitute the GSL versions via a
55
preprocessor macro if they are unavailable on another platform.
57
<p>For example, after determining whether the BSD function <code>hypot</code> is
58
available you can include the following macro definitions in a file
59
<samp><span class="file">config.h</span></samp> with your application,
61
<pre class="example"> /* Substitute gsl_hypot for missing system hypot */
64
#define hypot gsl_hypot
67
<p class="noindent">The application source files can then use the include command
68
<code>#include <config.h></code> to replace each occurrence of <code>hypot</code> by
69
<code>gsl_hypot</code> when <code>hypot</code> is not available. This substitution
70
can be made automatically if you use <code>autoconf</code>, see <a href="Autoconf-Macros.html#Autoconf-Macros">Autoconf Macros</a>.
72
<p>In most circumstances the best strategy is to use the native versions of
73
these functions when available, and fall back to GSL versions otherwise,
74
since this allows your application to take advantage of any
75
platform-specific optimizations in the system library. This is the
76
strategy used within GSL itself.