<!DOCTYPE html>
<html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-menu-disabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-0 vector-toc-not-available vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-0 skin-theme-clientpref-os vector-feature-navigation-update-disabled vector-sticky-header-enabled skin-thumbsize-clientpref-standard" lang="it" dir="ltr"><head>
    <meta charset="UTF-8">
    <title>Stddef.h</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/png" href="./_res_/favicon.png">
    <link rel="canonical" href="https://it.wikipedia.org/wiki/Stddef.h"> <link href="./_mw_/ext.pygments.css" rel="stylesheet" type="text/css">
    <link href="./_mw_/ext.wikimediamessages.styles.css" rel="stylesheet" type="text/css">
    <link href="./_mw_/mediawiki.skinning.content.parsoid.css" rel="stylesheet" type="text/css">
    <link href="./_mw_/skins.vector.icons.css" rel="stylesheet" type="text/css">
    <link href="./_mw_/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
    <link href="./_mw_/skins.vector.styles.css" rel="stylesheet" type="text/css">
    <meta name="ResourceLoaderDynamicStyles" content="">
    
    <link rel="stylesheet" type="text/css" href="./_mw_/site.styles.css">
    <link rel="stylesheet" type="text/css" href="./_mw_/noscript.css">
    <link rel="stylesheet" type="text/css" href="./_res_/footer.css">
    <link rel="stylesheet" type="text/css" href="./_res_/vector-2022.css">
  </head>
  <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Stddef_h rootpage-Stddef_h skin-vector-2022 action-view">
    <div class="mw-page-container">
      <div class="mw-page-container-inner">
        <div class="mw-content-container">
          <main id="content" class="mw-body">
            <header class="mw-body-header vector-page-titlebar">
              <h1 id="firstHeading" class="firstHeading mw-first-heading">stddef.h</h1>
            </header>
            <a id="top"></a>
            <div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
              <div id="contentSub">
                <div id="mw-content-subtitle"></div>
              </div>
              <div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="it" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="it" dir="ltr" data-mw-parsoid-version="0.24.0.0-alpha18" data-mw-html-version="2.8.0"><section data-mw-section-id="0" id="mwAQ">
<span typeof="mw:Transclusion" id="mwAw"></span>
<p id="mwBA"><b id="mwBQ">stddef.h</b> (<i id="mwBg">standard definition header</i>) è un <a rel="mw:WikiLink" href="Header_file" title="Header file" class="mw-redirect" id="mwBw">file d'intestazione</a> compreso nella <a rel="mw:WikiLink" href="Libreria_standard_del_C" title="Libreria standard del C" id="mwCA">libreria standard del C</a> che definisce le <a rel="mw:WikiLink" href="Macro_(informatica)" title="Macro (informatica)" id="mwCQ">macro</a> <a rel="mw:WikiLink" href="NULL" title="NULL" id="mwCg">NULL</a> e offsetof e i tipi ptrdiff_t, wchar_t, e size_t.</p>

</section><section data-mw-section-id="1" id="mwEA" aria-labelledby="Inclusione"><div class="mw-heading mw-heading2"><h2 id="Inclusione">Inclusione</h2></div>
<p id="mwEQ">In C, l'<a rel="mw:WikiLink" href="Header_file" title="Header file" class="mw-redirect" id="mwEg">header file</a> "stddef.h", si include scrivendo:</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr" typeof="mw:Extension/syntaxhighlight" id="mwEw"><pre id="mwFA"><span id="mwFQ"></span><span class="cp" id="mwFg">#include</span><span class="w" id="mwFw"> </span><span class="cpf" id="mwGA">&lt;stddef.h&gt;</span>
<span class="cm" id="mwGQ">/* ... */</span>
</pre></div>

<p id="mwGg">In C++, invece si include l'<a rel="mw:WikiLink" href="Header_file" title="Header file" class="mw-redirect" id="mwGw">header file</a> "cstddef", scrivendo:</p>
<div class="mw-highlight mw-highlight-lang-cpp mw-content-ltr" dir="ltr" typeof="mw:Extension/syntaxhighlight" id="mwHA"><pre id="mwHQ"><span id="mwHg"></span><span class="cp" id="mwHw">#include</span><span class="w" id="mwIA"> </span><span class="cpf" id="mwIQ">&lt;cstddef&gt;</span>
<span class="c1" id="mwIg">// ...</span>
</pre></div>

</section><section data-mw-section-id="2" id="mwIw" aria-labelledby="Namespace"><div class="mw-heading mw-heading2"><h2 id="Namespace">Namespace</h2></div>
<p id="mwJA">L'<a rel="mw:WikiLink" href="Header_file" title="Header file" class="mw-redirect" id="mwJQ">header file</a> "stddef.h" mette le sue definizioni in ambito globale; l'<a rel="mw:WikiLink" href="Header_file" title="Header file" class="mw-redirect" id="mwJg">header file</a> "cstddef" mette invece size_t e ptrdiff_t nel <a rel="mw:WikiLink" href="Namespace" title="Namespace" id="mwKQ">namespace</a> <i id="mwKg">std</i>.</p>

</section><section data-mw-section-id="3" id="mwKw" aria-labelledby="NULL"><div class="mw-heading mw-heading2"><h2 id="NULL">NULL</h2></div>
<p id="mwLA">È una macro che viene espansa in un puntatore a null costante.
Può essere definito come ((void*)0), 0 oppure 0L (zero Long) a seconda del compilatore e del linguaggio.</p>

</section><section data-mw-section-id="4" id="mwLQ" aria-labelledby="offsetof(tipo,_membro)"><div class="mw-heading mw-heading2"><h2 id="offsetof(tipo,_membro)"><span id="offsetof.28tipo.2C_membro.29" typeof="mw:FallbackId"></span>offsetof(tipo, membro)</h2></div>
<p id="mwLg">Una macro funzionale usata per determinare l'offset in byte del campo membro di una struct del tipo indicato.</p>

<p id="mwLw">Esempio:</p>

<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr" typeof="mw:Extension/syntaxhighlight" id="mwMA"><pre id="mwMQ"><span id="mwMg"></span><span class="k" id="mwMw">typedef</span><span class="w" id="mwNA"> </span><span class="k" id="mwNQ">struct</span><span class="w" id="mwNg"> </span><span class="nc" id="mwNw">provola</span>
<span class="p" id="mwOA">{</span>
<span class="w" id="mwOQ">  </span><span class="kt" id="mwOg">int</span><span class="w" id="mwOw"> </span><span class="n" id="mwPA">peso</span><span class="p" id="mwPQ">;</span>
<span class="w" id="mwPg">  </span><span class="kt" id="mwPw">char</span><span class="w" id="mwQA"> </span><span class="n" id="mwQQ">colore</span><span class="p" id="mwQg">;</span>

<span class="p" id="mwQw">}</span><span class="w" id="mwRA"> </span><span class="n" id="mwRQ">PROVOLA</span><span class="p" id="mwRg">;</span>

<span class="kt" id="mwRw">int</span><span class="w" id="mwSA"> </span><span class="nf" id="mwSQ">main</span><span class="p" id="mwSg">()</span>
<span class="p" id="mwSw">{</span>
<span class="w" id="mwTA"> </span><span class="p" id="mwTQ">...</span>
<span class="w" id="mwTg">  </span><span class="n" id="mwTw">printf</span><span class="p" id="mwUA">(</span><span class="s" id="mwUQ">"%d"</span><span class="p" id="mwUg">,</span><span class="n" id="mwUw">offsetof</span><span class="p" id="mwVA">(</span><span class="n" id="mwVQ">PROVOLA</span><span class="p" id="mwVg">,</span><span class="n" id="mwVw">colore</span><span class="p" id="mwWA">));</span>
<span class="p" id="mwWQ">}</span>
</pre></div>

<p id="mwWg">Il programma sopra stampa su schermo il numero di byte a partire dal quale si trova colore; se ad esempio sizeof(int) vale 4 darà 4.</p>

</section><section data-mw-section-id="5" id="mwWw" aria-labelledby="Tipo_size_t"><div class="mw-heading mw-heading2"><h2 id="Tipo_size_t">Tipo size_t</h2></div>
<p id="mwXA">Il tipo size_t è il tipo appropriato per rappresentare la dimensione di oggetti che stanno in aree di memoria, e per dereferenziare gli elementi di un array. Ha una dimensione che dipende dall'implementazione; in genere ha una rappresentazione a 32 bit nei sistemi a 32 bit e una rappresentazione a 64 bit nei sistemi a 64 bit. È unsigned. Ha una variante signed, ssize_t, definita nell'<a rel="mw:WikiLink" href="Header_file" title="Header file" class="mw-redirect" id="mwYQ">header file</a>, "unistd.h" di <a rel="mw:WikiLink" href="UNIX" title="UNIX" class="mw-redirect" id="mwYg">UNIX</a>.</p>

</section><section data-mw-section-id="6" id="mwYw" aria-labelledby="Tipo_wchar_t"><div class="mw-heading mw-heading2"><h2 id="Tipo_wchar_t">Tipo wchar_t</h2></div>
<p id="mwZA">Sta per "wide character type" ed è un tipo inteso a rappresentare un carattere generico (più generico di <a rel="mw:WikiLink" href="Carattere_(informatica)" title="Carattere (informatica)" id="mwZQ">char</a> che rappresenta solo i caratteri del codice <a rel="mw:WikiLink" href="ASCII" title="ASCII" id="mwZg">ASCII</a>); è predefinto in <a rel="mw:WikiLink" href="C%2B%2B" title="C++" id="mwZw">C++</a> mentre richiede l'<a rel="mw:WikiLink" href="Header_file" title="Header file" class="mw-redirect" id="mwaA">header file</a> "stddef.h" o il "wchar.h" in <a rel="mw:WikiLink" href="Linguaggio_C" title="Linguaggio C" class="mw-redirect" id="mwaQ">C</a>.</p>

</section><section data-mw-section-id="7" id="mwag" aria-labelledby="Tipo_ptrdiff_t"><div class="mw-heading mw-heading2"><h2 id="Tipo_ptrdiff_t">Tipo ptrdiff_t</h2></div>
<p id="mwaw">Il tipo ptrdiff_t serve a contenere il risultato della sottrazione tra due puntatori. Il tipo reale sottostante di ptrdiff_t varia da implementazione a implementazione.</p>

</section><section data-mw-section-id="8" id="mwbg" aria-labelledby="Collegamenti_esterni"><div class="mw-heading mw-heading2"><h2 id="Collegamenti_esterni">Collegamenti esterni</h2></div>
<ul id="mwbw"><li id="mwcA"><a rel="mw:ExtLink nofollow" href="https://web.archive.org/web/20090511184941/http://www.opengroup.org/pubs/online/7908799/xsh/stddef.h.html" class="external text" id="mwcQ">stddef.h</a> on <a rel="mw:WikiLink" href="The_Open_Group" title="The Open Group" id="mwcg">The Open Group</a></li>
<li id="mwcw"><a rel="mw:ExtLink nofollow" href="http://www.cplusplus.com/reference/clibrary/cstddef/" class="external text" id="mwdA">stddef.h</a> <a rel="mw:ExtLink nofollow" href="https://web.archive.org/web/20091027071408/http://www.cplusplus.com/reference/clibrary/cstddef/" typeof="mw:Transclusion" class="external text" id="mwdQ">Archiviato</a><span> il 27 ottobre 2009 in </span><a rel="mw:WikiLink" href="Internet_Archive" title="Internet Archive">Internet Archive</a><span>.</span> on CPlusPlus.com</li>
<li id="mweA"><a rel="mw:ExtLink nofollow" href="http://msdn2.microsoft.com/en-us/library/2b6eh9x3(VS.80).aspx" class="external text" id="mweQ">cstddef</a> on <a rel="mw:WikiLink" href="MSDN" title="MSDN" class="mw-redirect" id="mweg">MSDN</a></li></ul>



</section></div><!--htdig_noindex--><div><div class="zim-footer">
    Questa voce è stata pubblicata da <a class="external text" title="Ultima modifica il 2023-09-20" href="https://it.wikipedia.org/wiki/?title=Stddef.h&amp;oldid=135574186">Wikipedia</a>. Il testo è rilasciato in base alla licenza <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.it">Creative Commons Attribution-Share Alike 4.0</a>, salvo diversa indicazione. Potrebbero essere applicate clausole aggiuntive per i file multimediali.
</div>
</div><!--/htdig_noindex--></div>
            </div>
          </main>
        </div>
      </div>
    </div>
     <script src="./_webp_/webpHandler.js"></script>
  

</body></html>