PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 1ms

/trunk/Examples/perl5/constants/index.html

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