PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/go/constants/index.html

#
HTML | 55 lines | 44 code | 11 blank | 0 comment | 0 complexity | e4fa21572e2b31b67e2d9d848fb07d69 MD5 | raw file
 1<html>
 2<head>
 3<title>SWIG:Examples:go:constants</title>
 4</head>
 5
 6<body bgcolor="#ffffff">
 7
 8<tt>SWIG/Examples/go/constants/</tt>
 9<hr>
10
11<H2>Wrapping C Constants</H2>
12
13<p>
14When SWIG encounters C preprocessor macros and C declarations that
15look like constants, it creates a Go constant with an identical value.
16Click <a href="example.i">here</a> to see a SWIG interface with some
17constant declarations in it.
18
19
20<h2>Accessing Constants from Go</h2>
21Click <a href="../../../Doc/Manual/Go.html#go_constants">here</a> for
22the section on constants in the SWIG and Go documentation.
23<p>
24
25Click <a href="runme.go">here</a> to see a Go program that prints out
26the values of the constants contained in the above file.</p>
27<h2>Key points</h2>
28<ul>
29<li>All names are capitalized to make them visible.
30<li>The values of preprocessor macros are converted into Go constants.
31<li>C string literals such as "Hello World" are converted into Go strings.
32<li>Macros that are not fully defined are simply ignored.  For example:
33<blockquote>
34<pre>
35#define EXTERN extern
36</pre>
37</blockquote>
38is ignored because SWIG has no idea what type of variable this would be.
39
40<p>
41<li>Expressions are allowed provided that all of their components are
42defined. Otherwise, the constant is ignored.
43
44<li>Certain C declarations involving 'const' are also turned into Go
45constants.
46<li>The constants that appear in a SWIG interface file do not have to
47appear in any sort of matching C source file since the creation of a
48constant does not require linkage to a stored value (i.e., a value
49held in a C global variable or memory location).
50</ul>
51
52<hr>
53
54</body>
55</html>