/usr/share/doc/racket/inside/embedding.html is in racket-doc 6.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>2 Embedding into a Program</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">▼</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Inside:<span class="mywbr"> </span> Racket C API</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="overview.html" class="tocviewlink" data-pltdoc="x">Overview</a></td></tr><tr><td align="right">2 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Embedding into a Program</a></td></tr><tr><td align="right">3 </td><td><a href="Writing_Racket_Extensions.html" class="tocviewlink" data-pltdoc="x">Writing Racket Extensions</a></td></tr><tr><td align="right">4 </td><td><a href="im_values_types.html" class="tocviewlink" data-pltdoc="x">Values and Types</a></td></tr><tr><td align="right">5 </td><td><a href="im_memoryalloc.html" class="tocviewlink" data-pltdoc="x">Memory Allocation</a></td></tr><tr><td align="right">6 </td><td><a href="im_env.html" class="tocviewlink" data-pltdoc="x">Namespaces and Modules</a></td></tr><tr><td align="right">7 </td><td><a href="Procedures.html" class="tocviewlink" data-pltdoc="x">Procedures</a></td></tr><tr><td align="right">8 </td><td><a href="Evaluation.html" class="tocviewlink" data-pltdoc="x">Evaluation</a></td></tr><tr><td align="right">9 </td><td><a href="exceptions.html" class="tocviewlink" data-pltdoc="x">Exceptions and Escape Continuations</a></td></tr><tr><td align="right">10 </td><td><a href="threads.html" class="tocviewlink" data-pltdoc="x">Threads</a></td></tr><tr><td align="right">11 </td><td><a href="config.html" class="tocviewlink" data-pltdoc="x">Parameterizations</a></td></tr><tr><td align="right">12 </td><td><a href="contmarks.html" class="tocviewlink" data-pltdoc="x">Continuation Marks</a></td></tr><tr><td align="right">13 </td><td><a href="im_encodings.html" class="tocviewlink" data-pltdoc="x">String Encodings</a></td></tr><tr><td align="right">14 </td><td><a href="Bignums__Rationals__and_Complex_Numbers.html" class="tocviewlink" data-pltdoc="x">Bignums, Rationals, and Complex Numbers</a></td></tr><tr><td align="right">15 </td><td><a href="Ports_and_the_Filesystem.html" class="tocviewlink" data-pltdoc="x">Ports and the Filesystem</a></td></tr><tr><td align="right">16 </td><td><a href="Structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">17 </td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Security Guards</a></td></tr><tr><td align="right">18 </td><td><a href="Custodians.html" class="tocviewlink" data-pltdoc="x">Custodians</a></td></tr><tr><td align="right">19 </td><td><a href="Subprocesses.html" class="tocviewlink" data-pltdoc="x">Subprocesses</a></td></tr><tr><td align="right">20 </td><td><a href="Miscellaneous_Utilities.html" class="tocviewlink" data-pltdoc="x">Miscellaneous Utilities</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">►</a></td><td>2 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Embedding into a Program</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">2.1 </td><td><a href="#%28part._.C.G.C_.Embedding%29" class="tocviewlink" data-pltdoc="x">CGC Embedding</a></td></tr><tr><td align="right">2.2 </td><td><a href="#%28part._3m_.Embedding%29" class="tocviewlink" data-pltdoc="x">3m Embedding</a></td></tr><tr><td align="right">2.3 </td><td><a href="#%28part._.Flags_and_.Hooks%29" class="tocviewlink" data-pltdoc="x">Flags and Hooks</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">2.1<tt> </tt></span><a href="#%28part._.C.G.C_.Embedding%29" class="tocsubseclink" data-pltdoc="x">CGC Embedding</a></td></tr><tr><td><span class="tocsublinknumber">2.2<tt> </tt></span><a href="#%28part._3m_.Embedding%29" class="tocsubseclink" data-pltdoc="x">3m Embedding</a></td></tr><tr><td><span class="tocsublinknumber">2.3<tt> </tt></span><a href="#%28part._.Flags_and_.Hooks%29" class="tocsubseclink" data-pltdoc="x">Flags and Hooks</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="overview.html" title="backward to "1 Overview"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Inside: Racket C API"" data-pltdoc="x">up</a> <a href="Writing_Racket_Extensions.html" title="forward to "3 Writing Racket Extensions"" data-pltdoc="x">next →</a></span> </div><h3 x-source-module="(lib "scribblings/inside/inside.scrbl")" x-source-pkg="racket-doc" x-part-tag=""embedding"">2<tt> </tt><a name="(part._embedding)"></a><a name="(idx._(gentag._2._(lib._scribblings/inside/inside..scrbl)))"></a>Embedding into a Program</h3><p>The Racket run-time system can be embedded into a larger program. The
embedding process for Racket CGC or Racket 3m (see <a href="overview.html#%28part._.C.G.C._versus._3m%29" data-pltdoc="x">CGC versus 3m</a>)
is essentially the same, but the process for Racket 3m is most easily
understood as a variant of the process for Racket CGC (even though
Racket 3m is the standard variant of Racket).</p><h4 x-source-module="(lib "scribblings/inside/inside.scrbl")" x-source-pkg="racket-doc" x-part-tag=""CGC_Embedding"">2.1<tt> </tt><a name="(part._.C.G.C_.Embedding)"></a>CGC Embedding</h4><p>To embed Racket CGC in a program, follow these steps:</p><ul><li><p>Locate or build the Racket CGC libraries. Since the
standard distribution provides 3m libraries, only, you will most
likely have to build from source.</p><p>On Unix, the libraries are <a name="(idx._(gentag._3._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libracket.a"</span>
and <a name="(idx._(gentag._4._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libmzgc.a"</span> (or
<a name="(idx._(gentag._5._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libracket.so"</span> and
<a name="(idx._(gentag._6._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libmzgc.so"</span> for a dynamic-library build, with
<a name="(idx._(gentag._7._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libracket.la"</span> and
<a name="(idx._(gentag._8._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libmzgc.la"</span> files for use with
<span class="stt">libtool</span>). Building from source and installing places the
libraries into the installation’s <span class="stt">"lib"</span> directory. Be sure
to build the CGC variant, since the default is 3m.</p><p>On Windows, stub libraries for use with Microsoft tools are
<span class="stt">"libracket<span style="font-style: italic">x</span>.lib"</span> and
<span class="stt">"libmzgc<span style="font-style: italic">x</span>.lib"</span> (where <span style="font-style: italic">x</span> represents the
version number) are in a compiler-specific directory in
<span class="stt">"racket\lib"</span>. These libraries identify the bindings that are
provided by <span class="stt">"libracket<span style="font-style: italic">x</span>.dll"</span> and
<span class="stt">"libmzgc<span style="font-style: italic">x</span>.dll"</span> —<wbr></wbr> which are typically installed
in <span class="stt">"racket\lib"</span>. When linking with Cygwin, link to
<span class="stt">"libracket<span style="font-style: italic">x</span>.dll"</span> and
<span class="stt">"libmzgc<span style="font-style: italic">x</span>.dll"</span> directly. At run time, either
<span class="stt">"libracket<span style="font-style: italic">x</span>.dll"</span> and
<span class="stt">"libmzgc<span style="font-style: italic">x</span>.dll"</span> must be moved to a location in the
standard DLL search path, or your embedding application must
“delayload” link the DLLs and explicitly load them before
use. (<span class="stt">"Racket.exe"</span> and <span class="stt">"GRacket.exe"</span> use the latter
strategy.)</p><p>On Mac OS X, dynamic libraries are provided by the
<span class="stt">"Racket"</span> framework, which is typically installed in
<span class="stt">"lib"</span> sub-directory of the installation. Supply
<span class="stt">-framework Racket</span> to <span class="stt">gcc</span> when linking, along
with <span class="stt">-F</span> and a path to the <span class="stt">"lib"</span> directory. Beware
that CGC and 3m libraries are installed as different versions within
a single framework, and installation marks one version or the other
as the default (by setting symbolic links); install only CGC to
simplify accessing the CGC version within the framework. At run
time, either <span class="stt">"Racket.framework"</span> must be moved to a
location in the standard framework search path, or your embedding
executable must provide a specific path to the framework (possibly
an executable-relative path using the Mach-O <span class="stt">@executable_path</span>
prefix).</p></li><li><p>For each C/C++ file that uses Racket library functions,
<span class="stt">#include</span> the file <a name="(idx._(gentag._9._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"scheme.h"</span>.</p><p>The C preprocessor symbol <span class="stt">SCHEME_DIRECT_EMBEDDED</span> is defined
as <span class="stt">1</span> when <span class="stt">"scheme.h"</span> is <span class="stt">#include</span>d, or as
<span class="stt">0</span> when <span class="stt">"escheme.h"</span> is <span class="stt">#include</span>d.</p><p>The <span class="stt">"scheme.h"</span> file is distributed with the Racket software in
the installation’s <span class="stt">"include"</span> directory. Building and
installing from source also places this file in the installation’s
<span class="stt">"include"</span> directory.</p></li><li><p>Start your main program through the <a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a> (or
<a href="im_memoryalloc.html#%28cpp._scheme_main_stack_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_stack_setup</span></a>) trampoline, and put all uses of
Racket functions inside the function passed to
<a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a>. The <a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a> function
registers the current C stack location with the memory manager. It
also creates the initial namespace <span class="stt">Scheme_Env*</span> by calling
<a href="Evaluation.html#%28cpp._scheme_basic_env%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_basic_env</span></a> and passing the result to the function
provided to <a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a>. (The
<a href="im_memoryalloc.html#%28cpp._scheme_main_stack_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_stack_setup</span></a> trampoline registers the C stack with
the memory manager without creating a namespace.)</p><p>On Windows, when support for parallelism is enabled in the Racket
build (as is the default), then before calling
<a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a>, your embedding application must first call
<a href="im_memoryalloc.html#%28cpp._scheme_register_tls_space%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_register_tls_space</span></a>:</p><p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="hspace"> </span><span class="stt">scheme_register_tls_space(&tls_space, 0);</span></p></td></tr></table></p><p>where <span class="stt">tls_space</span> is declared as a thread-local pointer variable
in the main executable (i.e., not in a dynamically linked DLL):</p><p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="hspace"> </span><span class="stt">static __declspec(thread) void *tls_space;</span></p></td></tr></table></p><p class="SHistory">Changed in version 6.3: Calling <a href="im_memoryalloc.html#%28cpp._scheme_register_tls_space%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_register_tls_space</span></a> is
required on all Windows variants, although the call
may be a no-op, depending on how Racket is
built.</p></li><li><p>Configure the namespace by adding module declarations. The
initial namespace contains declarations only for a few primitive
modules, such as <span class="RktVal">'</span><span class="RktVal">#%kernel</span>, and no bindings are imported
into the top-level environment.</p><p>To embed a module like <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=index.html&version=6.7" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket/base</span></a> (along with all
its dependencies), use
<a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=raco&rel=c-mods.html&version=6.7" class="Sq" data-pltdoc="x"><span class="stt">raco ctool --c-mods </span><span class="sroman">‹<span style="font-style: italic">dest</span>›</span></a>,
which generates a C file <span class="sroman">‹<span style="font-style: italic">dest</span>›</span>
that contains modules in bytecode form as encapsulated in a static
array. The generated C file defines a <span class="stt">declare_modules</span>
function that takes a <span class="stt">Scheme_Env*</span>, installs the modules into
the environment, and adjusts the module name resolver to access the
embedded declarations. If embedded modules refer to runtime files
that need to be carried along, supply <span class="nobreak"><span class="stt">--runtime</span></span> to
<span class="stt">raco ctool --c-mods</span> to collect the runtime files into a
directory; see <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=raco&rel=c-mods.html&version=6.7" class="Sq" data-pltdoc="x">Embedding Modules via C</a> for more information.</p><p>Alternatively, use <a href="#%28cpp._scheme_set_collects_path%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_set_collects_path</span></a> and
<a href="#%28cpp._scheme_init_collection_paths%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_init_collection_paths</span></a> to configure and install a path
for finding modules at run time.</p><p>On Windows, <span class="stt">raco ctool --c-mods </span><span class="sroman">‹<span style="font-style: italic">dest</span>›</span><span class="stt"> --runtime</span><span class="stt">
</span><span class="sroman">‹<span style="font-style: italic">dest-dir</span>›</span> includes in <span class="sroman">‹<span style="font-style: italic">dest-dir</span>›</span> optional DLLs
that are referenced by the Racket library to support <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=extflonums.html%23%2528tech._extflonum%2529&version=6.7" class="techoutside Sq" data-pltdoc="x"><span class="techinside">extflonums</span></a> and <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=bytestrings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._bytes-open-converter%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">bytes-open-converter</a></span>. Call
<a href="#%28cpp._scheme_set_dll_path%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_set_dll_path</span></a> to register <span class="sroman">‹<span style="font-style: italic">dest-dir</span>›</span> so that
those DLLs can be found at run time.</p></li><li><p>Access Racket through <a href="Miscellaneous_Utilities.html#%28cpp._scheme_dynamic_require%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_dynamic_require</span></a>,
<a href="Miscellaneous_Utilities.html#%28cpp._scheme_load%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_load</span></a>, <a href="Evaluation.html#%28cpp._scheme_eval%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_eval</span></a>, and/or other functions
described in this manual.</p><p>If the embedding program configures built-in parameters in a way
that should be considered part of the default configuration, then
call <a href="#%28cpp._scheme_seal_parameters%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_seal_parameters</span></a> afterward. The snapshot of
parameter values taken by <a href="#%28cpp._scheme_seal_parameters%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_seal_parameters</span></a> is used for
certain privileged operations, such as installing a <span class="planetName">PLaneT</span>
package.</p></li><li><p>Compile the program and link it with the Racket libraries.</p></li></ul><p><a name="(idx._(gentag._10._(lib._scribblings/inside/inside..scrbl)))"></a>With Racket CGC, Racket values are
garbage collected using a conservative garbage collector, so pointers
to Racket objects can be kept in registers, stack variables, or
structures allocated with <a href="im_memoryalloc.html#%28cpp._scheme_malloc%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_malloc</span></a>. In an embedding
application on some platforms, static variables are also automatically
registered as roots for garbage collection (but see notes below
specific to Mac OS X and Windows).</p><p>For example, the following is a simple embedding program which
evaluates all expressions provided on the command line and displays
the results, then runs a <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=Reading.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._read%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">read</a></span>-<span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=eval.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._eval%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">eval</a></span>-<span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._print%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">print</a></span>
loop. Run</p><p><span class="hspace"> </span><span class="stt">raco ctool --c-mods base.c ++lib racket/base</span></p><p>to generate <span class="stt">"base.c"</span>, which encapsulates <span class="RktSym">racket/base</span>
and all of its transitive imports (so that they need not be found
separately a run time).</p><p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="hspace"> </span><span class="stt">#include "scheme.h"</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">#include "base.c"</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">static int run(Scheme_Env *e, int argc, char *argv[])</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">{</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">Scheme_Object *curout;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">int i;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">Scheme_Thread *th;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">mz_jmp_buf * volatile save, fresh;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">/* Declare embedded modules in "base.c": */</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">declare_modules(e);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_namespace_require(scheme_intern_symbol("racket/base"));</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">curout = scheme_get_param(scheme_current_config(),</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZCONFIG_OUTPUT_PORT);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">th = scheme_get_current_thread();</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">for (i = 1; i < argc; i++) {</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">save = th->error_buf;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">th->error_buf = &fresh;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">if (scheme_setjmp(*th->error_buf)) {</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">th->error_buf = save;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">return -1; /* There was an error */</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">} else {</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">Scheme_Object *v, *a[2];</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">v = scheme_eval_string(argv[i], e);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_display(v, curout);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_display(scheme_make_char('\n'), curout);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">/* read-eval-print loop, uses initial Scheme_Env: */</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">a[0] = scheme_intern_symbol("racket/base");</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">a[1] = scheme_intern_symbol("read-eval-print-loop");</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_apply(scheme_dynamic_require(2, a), 0, NULL);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">th->error_buf = save;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">}</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">}</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">return 0;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">}</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">int main(int argc, char *argv[])</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">{</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">return scheme_main_setup(1, run, argc, argv);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">}</span></p></td></tr></table></p><p>If modules embedded in the executable need to access runtime files
(via <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528mod-path._racket%252Fruntime-path%2529&version=6.7" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket/runtime-path</span></a> forms), supply the
<span class="nobreak"><span class="stt">--runtime</span></span> flag to <span class="stt">raco ctool</span>, specifying a directory
where the runtime files are to be gathered. The modules in the
generated <span class="stt">".c"</span> file will then refer to the files in that
directory; the directory is normally specified relative to the
executable, but the embedding application must call
<a href="#%28cpp._scheme_set_exec_cmd%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_set_exec_cmd</span></a> to set the executable path (typically
<span class="stt">argv[0]</span>) before declaring modules.</p><p>On Mac OS X, or on Windows when Racket is compiled to a DLL
using Cygwin, the garbage collector cannot find static variables
automatically. In that case, <a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a> must be called with a
non-zero first argument.</p><p>On Windows (for any other build mode), the garbage collector finds
static variables in an embedding program by examining all memory
pages. This strategy fails if a program contains multiple Windows
threads; a page may get unmapped by a thread while the collector is
examining the page, causing the collector to crash. To avoid this
problem, call <a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a> with a non-zero first argument.</p><p>When an embedding application calls <a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a> with a non-zero
first argument, it must register each of its static variables with
<span class="stt">MZ_REGISTER_STATIC</span> if the variable can contain a GCable
pointer. For example, if <span class="stt">curout</span> above is made <span class="stt">static</span>, then
<span class="stt">MZ_REGISTER_STATIC(curout)</span> should be inserted before the call to
<a href="config.html#%28cpp._scheme_get_param%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_get_param</span></a>.</p><p>When building an embedded Racket CGC to use SenoraGC (SGC) instead of
the default collector, <a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a> must be called with a
non-zero first argument. See <a href="im_memoryalloc.html" data-pltdoc="x">Memory Allocation</a> for more
information.</p><h4 x-source-module="(lib "scribblings/inside/inside.scrbl")" x-source-pkg="racket-doc" x-part-tag=""3m_Embedding"">2.2<tt> </tt><a name="(part._3m_.Embedding)"></a>3m Embedding</h4><p>Racket 3m can be embedded mostly the same as Racket, as long as the
embedding program cooperates with the precise garbage collector as
described in <a href="im_memoryalloc.html#%28part._im~3a3m%29" data-pltdoc="x">Cooperating with 3m</a>.</p><p>In either your source in the in compiler command line, <span class="stt">#define</span>
<span class="stt">MZ_PRECISE_GC</span> before including <span class="stt">"scheme.h"</span>. When using
<span class="stt">raco ctool</span> with the <span class="nobreak"><span class="stt">--cc</span></span> and <span class="nobreak"><span class="stt">--3m</span></span> flags, <span class="stt">MZ_PRECISE_GC</span>
is automatically defined.</p><p>In addition, some library details are different:</p><ul><li><p>On Unix, the library is just
<a name="(idx._(gentag._11._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libracket3m.a"</span> (or
<a name="(idx._(gentag._12._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libracket3m.so"</span> for a dynamic-library build,
with <a name="(idx._(gentag._13._(lib._scribblings/inside/inside..scrbl)))"></a><span class="stt">"libracket3m.la"</span> for use with
<span class="stt">libtool</span>). There is no separate library for 3m analogous to
CGC’s <span class="stt">"libmzgc.a"</span>.</p></li><li><p>On Windows, the stub library for use with Microsoft tools is
<span class="stt">"libracket3m<span style="font-style: italic">x</span>.lib"</span> (where <span style="font-style: italic">x</span> represents the
version number). This library identifies the bindings that are
provided by <span class="stt">"libracket3m<span style="font-style: italic">x</span>.dll"</span>. There is no
separate library for 3m analogous to CGC’s
<span class="stt">"libmzgc<span style="font-style: italic">x</span>.lib"</span>.</p></li><li><p>On Mac OS X, 3m dynamic libraries are provided by the
<span class="stt">"Racket"</span> framework, just as for CGC, but as a version
suffixed with <span class="stt">"_3m"</span>.</p></li></ul><p>For Racket 3m, an embedding application must call <a href="im_memoryalloc.html#%28cpp._scheme_main_setup%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_main_setup</span></a>
with a non-zero first argument.</p><p>The simple embedding program from the previous section can be
processed by <span class="stt">raco ctool --xform</span>, then compiled and linked with
Racket 3m. Alternately, the source code can be extended to work with
either CGC or 3m depending on whether <span class="stt">MZ_PRECISE_GC</span> is defined
on the compiler’s command line:</p><p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="hspace"> </span><span class="stt">#include "scheme.h"</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">#include "base.c"</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">static int run(Scheme_Env *e, int argc, char *argv[])</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">{</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">Scheme_Object *curout = NULL, *v = NULL, *a[2] = {NULL, NULL};</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">Scheme_Config *config = NULL;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">int i;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">Scheme_Thread *th = NULL;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">mz_jmp_buf * volatile save = NULL, fresh;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_DECL_REG(9);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_VAR_IN_REG(0, e);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_VAR_IN_REG(1, curout);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_VAR_IN_REG(2, save);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_VAR_IN_REG(3, config);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_VAR_IN_REG(4, v);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_VAR_IN_REG(5, th);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_ARRAY_VAR_IN_REG(6, a, 2);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_REG();</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">declare_modules(e);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">v = scheme_intern_symbol("racket/base");</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_namespace_require(v);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">config = scheme_current_config();</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">curout = scheme_get_param(config, MZCONFIG_OUTPUT_PORT);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">th = scheme_get_current_thread();</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">for (i = 1; i < argc; i++) {</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">save = th->error_buf;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">th->error_buf = &fresh;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">if (scheme_setjmp(*th->error_buf)) {</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">th->error_buf = save;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">return -1; /* There was an error */</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">} else {</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">v = scheme_eval_string(argv[i], e);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_display(v, curout);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">v = scheme_make_char('\n');</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_display(v, curout);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">/* read-eval-print loop, uses initial Scheme_Env: */</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">a[0] = scheme_intern_symbol("racket/base");</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">a[1] = scheme_intern_symbol("read-eval-print-loop");</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">v = scheme_dynamic_require(2, a);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_apply(v, 0, NULL);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">th->error_buf = save;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">}</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">}</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">MZ_GC_UNREG();</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">return 0;</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">}</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">int main(int argc, char *argv[])</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">{</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">return scheme_main_setup(1, run, argc, argv);</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">}</span></p></td></tr></table></p><p>Strictly speaking, the <span class="stt">config</span> and <span class="stt">v</span> variables above need
not be registered with the garbage collector, since their values are
not needed across function calls that allocate. The code is much
easier to maintain, however, when all local variables are registered
and when all temporary values are put into variables.</p><h4 x-source-module="(lib "scribblings/inside/inside.scrbl")" x-source-pkg="racket-doc" x-part-tag=""Flags_and_Hooks"">2.3<tt> </tt><a name="(part._.Flags_and_.Hooks)"></a>Flags and Hooks</h4><p>The following flags and hooks are available when Racket is
embedded:</p><ul><li><p><a name="(cpp._scheme_exit)"></a><a name="(idx._(gentag._14._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_exit%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_exit</span></a> —<wbr></wbr> This pointer can be set to a function
that takes an integer argument and returns <span class="stt">void</span>; the function
will be used as the default exit handler. The default is <span class="stt">NULL</span>.</p></li><li><p><a name="(cpp._scheme_make_stdin)"></a><a name="(idx._(gentag._15._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_make_stdin%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_make_stdin</span></a>, <a name="(cpp._scheme_make_stdout)"></a><a name="(idx._(gentag._16._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_make_stdout%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_make_stdout</span></a>,
<a name="(cpp._scheme_make_stderr)"></a><a name="(idx._(gentag._17._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_make_stderr%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_make_stderr</span></a>, —<wbr></wbr> These pointers can be set to a
function that takes no arguments and returns a Racket port
<span class="stt">Scheme_Object *</span> to be used as the starting standard input,
output, and/or error port. The defaults are <span class="stt">NULL</span>. Setting the
initial error port is particularly important for seeing unexpected
error messages if <span class="stt">stderr</span> output goes nowhere.</p></li><li><p><a name="(cpp._scheme_console_output)"></a><a name="(idx._(gentag._18._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_console_output%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_console_output</span></a> —<wbr></wbr> This pointer can be set to a
function that takes a string and a <span class="stt">intptr_t</span> string length; the
function will be called to display internal Racket warnings and
messages that possibly contain non-terminating nuls. The default is
<span style="font-style: italic">NULL</span>.</p></li><li><p><a name="(cpp._scheme_check_for_break)"></a><a name="(idx._(gentag._19._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_check_for_break%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_check_for_break</span></a> —<wbr></wbr> This points to a function
of no arguments that returns an integer. It is used as the default
user-break polling procedure in the main thread. A non-zero return
value indicates a user break, and each time the function returns a
non-zero value, it counts as a new break signal (though the break
signal may be ignored if a previous signal is still pending). The
default is <span class="stt">NULL</span>.</p></li><li><p><a name="(cpp._scheme_case_sensitive)"></a><a name="(idx._(gentag._20._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_case_sensitive%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_case_sensitive</span></a> —<wbr></wbr> If this flag is set to a
non-zero value before <a href="Evaluation.html#%28cpp._scheme_basic_env%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_basic_env</span></a> is called, then
Racket will not ignore capitalization for symbols and global
variable names. The value of this flag should not change once it is
set. The default is zero.</p></li><li><p><a name="(cpp._scheme_allow_set_undefined)"></a><a name="(idx._(gentag._21._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_allow_set_undefined%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_allow_set_undefined</span></a> —<wbr></wbr> This flag determines
the initial value of <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=eval.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._compile-allow-set%2521-undefined%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">compile-allow-set!-undefined</a></span>. The default
is zero.</p></li><li><p><a name="(cpp._scheme_console_printf)"></a><a name="(idx._(gentag._22._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_console_printf%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_console_printf</span></a> —<wbr></wbr> This function pointer was
left for backward compatibility. The default builds a string and
calls <a href="#%28cpp._scheme_console_output%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_console_output</span></a>.</p></li></ul><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_set_collects_path)"></a><a name="(idx._(gentag._23._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_set_collects_path%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_set_collects_path</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Object*</span><span class="hspace"> </span><span style="font-style: italic">path</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Sets the path to be returned by <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._find-system-path%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">find-system-path</a></span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">collects-dir</span><span class="RktPn">)</span>.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_set_addon_path)"></a><a name="(idx._(gentag._24._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_set_addon_path%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_set_addon_path</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Object*</span><span class="hspace"> </span><span style="font-style: italic">path</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Sets the path to be returned by <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._find-system-path%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">find-system-path</a></span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">addon-dir</span><span class="RktPn">)</span>.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_set_exec_cmd)"></a><a name="(idx._(gentag._25._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_set_exec_cmd%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_set_exec_cmd</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">const char*</span><span class="hspace"> </span><span style="font-style: italic">path</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Sets the path to be returned by <span class="RktPn">(</span><span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=Filesystem.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._find-system-path%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">find-system-path</a></span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">exec-file</span><span class="RktPn">)</span>.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td colspan="3"><p><span class="stt">void</span></p></td></tr><tr><td><p><a name="(cpp._scheme_init_collection_paths_post)"></a><a name="(idx._(gentag._26._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_init_collection_paths_post%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_init_collection_paths_post</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Env*</span><span class="hspace"> </span><span style="font-style: italic">env</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">Scheme_Object*</span><span class="hspace"> </span><span style="font-style: italic">pre_extra_paths</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">Scheme_Object*</span><span class="hspace"> </span><span style="font-style: italic">post_extra_paths</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Initializes the <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=collects.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._current-library-collection-paths%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">current-library-collection-paths</a></span> parameter
using <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=collects.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmisc..rkt%2529._find-library-collection-paths%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">find-library-collection-paths</a></span>. The
<span style="font-style: italic">pre_extra_paths</span> and <span style="font-style: italic">post_extra-paths</span> arguments are
propagated to <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=collects.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmisc..rkt%2529._find-library-collection-paths%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">find-library-collection-paths</a></span>.</div></p><p>The function calls <a href="#%28cpp._scheme_seal_parameters%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_seal_parameters</span></a> automatically.</p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_init_collection_paths)"></a><a name="(idx._(gentag._27._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_init_collection_paths%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_init_collection_paths</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">Scheme_Env*</span><span class="hspace"> </span><span style="font-style: italic">env</span><span class="stt">,</span></p></td></tr><tr><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="hspace"> </span></p></td><td><p><span class="stt">Scheme_Object*</span><span class="hspace"> </span><span style="font-style: italic">pre_extra_paths</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Like <a href="#%28cpp._scheme_init_collection_paths_post%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_init_collection_paths_post</span></a>, but with <span class="RktSym"><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&version=6.7" class="RktValLink Sq" data-pltdoc="x">null</a></span>
as the last argument.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_set_dll_path)"></a><a name="(idx._(gentag._28._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_set_dll_path%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_set_dll_path</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">wchar_t*</span><span class="hspace"> </span><span style="font-style: italic">path</span><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">On Windows only, sets the path used to find optional DLLs that are used
by the runtime system: <span class="stt">"longdouble.dll"</span> and one of <span class="stt">"iconv.dll"</span>,
<span class="stt">"libiconv.dll"</span>, or <span class="stt">"libiconv-2.dll"</span>. The given <span style="font-style: italic">path</span>
should be an absolute path.</div></p><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="boxed"><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">void</span></p></td><td><p><span class="hspace"> </span></p></td><td><p><a name="(cpp._scheme_seal_parameters)"></a><a name="(idx._(gentag._29._(lib._scribblings/inside/inside..scrbl)))"></a><a href="#%28cpp._scheme_seal_parameters%29" class="RktStxLink" data-pltdoc="x"><span class="stt">scheme_seal_parameters</span></a></p></td><td><p><span class="stt">(</span></p></td><td><p><span class="stt">)</span></p></td></tr></table></td></tr></table></div><div class="SIntrapara">Takes a snapshot of the current values of built-in parameters. These
values are used for privileged actions, such as installing a <span class="planetName">PLaneT</span>
package.</div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="overview.html" title="backward to "1 Overview"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Inside: Racket C API"" data-pltdoc="x">up</a> <a href="Writing_Racket_Extensions.html" title="forward to "3 Writing Racket Extensions"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|