Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As <a href="https://stackoverflow.com/questions/1358400/what-is-external-linkage-and-internal-linkage-in-c/1358622#1358622">dudewat said</a> <em>external</em> linkage means the symbol (function or global variable) is accessible throughout your program and <em>internal</em> linkage means that it's only accessible in one <a href="http://en.wikipedia.org/wiki/Translation_unit_%28programming%29" rel="noreferrer">translation unit</a>. </p> <p>You can explicitly control the linkage of a symbol by using the <code>extern</code> and <code>static</code> keywords. If the linkage isn't specified then the default linkage is <code>extern</code> for non-<code>const</code> symbols and <code>static</code> (internal) for <code>const</code> symbols.</p> <pre><code>// in namespace or global scope int i; // extern by default const int ci; // static by default extern const int eci; // explicitly extern static int si; // explicitly static // the same goes for functions (but there are no const functions) int foo(); // extern by default static int bar(); // explicitly static </code></pre> <p>Note that instead of using <code>static</code> for internal linkage it is better to use <a href="https://stackoverflow.com/questions/154469/unnamed-anonymous-namespaces-vs-static-functions">anonymous namespaces</a> into which you can also put <code>class</code>es. The linkage for anonymous namespaces has changed between C++98 and C++11 but the main thing is that they are unreachable from other translation units.</p> <pre><code>namespace { int i; // external linkage but unreachable from other translation units. class invisible_to_others { }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload