Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>gcc uses <code>__attribute__(( &lt;attr&gt; ))</code> to define <a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html" rel="nofollow">extra attributes</a> on functions.</p> <ul> <li><p><strong>pure</strong>: only accesses (but does not modify) parameters and global memory. GCC uses this information to determine if the optimizer can completely omit repeated calls to the function (local-memoization). Two notable pure functions are <code>strlen</code> and <code>memcmp</code>.</p></li> <li><p><strong>const</strong>: not to be confused with C++ const, const functions only accesses parameters and those parameters must not be pointers. It is basically a more restricted version of <code>pure</code>. The optimizer treats <code>const</code> functions that same as <code>pure</code>. Though in theory it could perform more aggressive (non-local) memoization than it does for <code>pure</code>.</p></li> </ul> <p>C++11's new attribute syntax (§7.6) was designed to do just this sort of thing. Currently you cannot use C++'s attribute syntax to set GCC attributes, but that will change in future gcc versions.</p> <p>So you will be able to assign the <code>pure</code> attribute to functions using the attribute syntax. But there isn't a standard <code>pure</code> attribute. pure will be compiler specific, but it will do the right thing on gcc.</p> <p>For the curious, here is the list of the standard attributes:</p> <ul> <li>align</li> <li>noreturn</li> <li><strike>override</strike></li> <li><strike>hiding</strike></li> <li><strike>base_check</strike></li> <li>carries_dependency</li> </ul>
 

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