Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / stabs / Global-Variables.html
blob5ccd00e0cb80508cce303fcb871b36e42af7b48a
1 <html lang="en">
2 <head>
3 <title>STABS</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="STABS">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Global%20Variables">Global Variables</a>,
13 Next:<a rel="next" accesskey="n" href="Register-Variables.html#Register%20Variables">Register Variables</a>,
14 Previous:<a rel="previous" accesskey="p" href="Stack-Variables.html#Stack%20Variables">Stack Variables</a>,
15 Up:<a rel="up" accesskey="u" href="Variables.html#Variables">Variables</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Global Variables</h3>
21 <p>A variable whose scope is not specific to just one source file is
22 represented by the <code>G</code> symbol descriptor. These stabs use the
23 <code>N_GSYM</code> stab type (C_GSYM for XCOFF). The type information for
24 the stab (see <a href="String-Field.html#String%20Field">String Field</a>) gives the type of the variable.
26 <p>For example, the following source code:
28 <pre class="example"> char g_foo = 'c';
29 </pre>
31 <p>yields the following assembly code:
33 <pre class="example"> .stabs "g_foo:G2",32,0,0,0 # 32 is N_GSYM
34 .global _g_foo
35 .data
36 _g_foo:
37 .byte 99
38 </pre>
40 <p>The address of the variable represented by the <code>N_GSYM</code> is not
41 contained in the <code>N_GSYM</code> stab. The debugger gets this information
42 from the external symbol for the global variable. In the example above,
43 the <code>.global _g_foo</code> and <code>_g_foo:</code> lines tell the assembler to
44 produce an external symbol.
46 <p>Some compilers, like GCC, output <code>N_GSYM</code> stabs only once, where
47 the variable is defined. Other compilers, like SunOS4 /bin/cc, output a
48 <code>N_GSYM</code> stab for each compilation unit which references the
49 variable.
51 </body></html>