⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 type-encoding.html

📁 自己收集的linux入门到学懂高级编程书集 包括linux程序设计第三版
💻 HTML
字号:
<html lang="en"><head><title>Using the GNU Compiler Collection (GCC)</title><meta http-equiv="Content-Type" content="text/html"><meta name="description" content="Using the GNU Compiler Collection (GCC)"><meta name="generator" content="makeinfo 4.6"><!--Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.   <p>Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being "GNU General Public License" and "FundingFree Software", the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below).  A copy of the license isincluded in the section entitled "GNU Free Documentation License".   <p>(a) The FSF's Front-Cover Text is:   <p>A GNU Manual   <p>(b) The FSF's Back-Cover Text is:   <p>You have freedom to copy and modify this GNU Manual, like GNU     software.  Copies published by the Free Software Foundation raise     funds for GNU development.--><meta http-equiv="Content-Style-Type" content="text/css"><style type="text/css"><!--  pre.display { font-family:inherit }  pre.format  { font-family:inherit }  pre.smalldisplay { font-family:inherit; font-size:smaller }  pre.smallformat  { font-family:inherit; font-size:smaller }  pre.smallexample { font-size:smaller }  pre.smalllisp    { font-size:smaller }--></style></head><body><div class="node"><p>Node:&nbsp;<a name="Type%20encoding">Type encoding</a>,Next:&nbsp;<a rel="next" accesskey="n" href="Garbage-Collection.html#Garbage%20Collection">Garbage Collection</a>,Previous:&nbsp;<a rel="previous" accesskey="p" href="Executing-code-before-main.html#Executing%20code%20before%20main">Executing code before main</a>,Up:&nbsp;<a rel="up" accesskey="u" href="Objective-C.html#Objective-C">Objective-C</a><hr><br></div><h3 class="section">Type encoding</h3><p>The Objective-C compiler generates type encodings for all thetypes.  These type encodings are used at runtime to find out informationabout selectors and methods and about objects and classes.   <p>The types are encoded in the following way:   <p><table><tr align="left"><td valign="top"><code>char</code></td><td valign="top"><code>c</code><br></td></tr><tr align="left"><td valign="top"><code>unsigned char</code></td><td valign="top"><code>C</code><br></td></tr><tr align="left"><td valign="top"><code>short</code></td><td valign="top"><code>s</code><br></td></tr><tr align="left"><td valign="top"><code>unsigned short</code></td><td valign="top"><code>S</code><br></td></tr><tr align="left"><td valign="top"><code>int</code></td><td valign="top"><code>i</code><br></td></tr><tr align="left"><td valign="top"><code>unsigned int</code></td><td valign="top"><code>I</code><br></td></tr><tr align="left"><td valign="top"><code>long</code></td><td valign="top"><code>l</code><br></td></tr><tr align="left"><td valign="top"><code>unsigned long</code></td><td valign="top"><code>L</code><br></td></tr><tr align="left"><td valign="top"><code>long long</code></td><td valign="top"><code>q</code><br></td></tr><tr align="left"><td valign="top"><code>unsigned long long</code></td><td valign="top"><code>Q</code><br></td></tr><tr align="left"><td valign="top"><code>float</code></td><td valign="top"><code>f</code><br></td></tr><tr align="left"><td valign="top"><code>double</code></td><td valign="top"><code>d</code><br></td></tr><tr align="left"><td valign="top"><code>void</code></td><td valign="top"><code>v</code><br></td></tr><tr align="left"><td valign="top"><code>id</code></td><td valign="top"><code>@</code><br></td></tr><tr align="left"><td valign="top"><code>Class</code></td><td valign="top"><code>#</code><br></td></tr><tr align="left"><td valign="top"><code>SEL</code></td><td valign="top"><code>:</code><br></td></tr><tr align="left"><td valign="top"><code>char*</code></td><td valign="top"><code>*</code><br></td></tr><tr align="left"><td valign="top">unknown type</td><td valign="top"><code>?</code><br></td></tr><tr align="left"><td valign="top">bit-fields</td><td valign="top"><code>b</code> followed by the starting position of the bit-field, the type of the bit-field and the size of the bit-field (the bit-fields encoding was changed from the NeXT's compiler encoding, see below)   <br></td></tr></table>   <p>The encoding of bit-fields has changed to allow bit-fields to be properlyhandled by the runtime functions that compute sizes and alignments oftypes that contain bit-fields.  The previous encoding contained only thesize of the bit-field.  Using only this information it is not possible toreliably compute the size occupied by the bit-field.  This is veryimportant in the presence of the Boehm's garbage collector because theobjects are allocated using the typed memory facility available in thiscollector.  The typed memory allocation requires information about wherethe pointers are located inside the object.   <p>The position in the bit-field is the position, counting in bits, of thebit closest to the beginning of the structure.   <p>The non-atomic types are encoded as follows:   <p><table><tr align="left"><td valign="top">pointers</td><td valign="top"><code>^</code> followed by the pointed type. <br></td></tr><tr align="left"><td valign="top">arrays</td><td valign="top"><code>[</code> followed by the number of elements in the array followed by the type of the elements followed by <code>]</code><br></td></tr><tr align="left"><td valign="top">structures</td><td valign="top"><code>{</code> followed by the name of the structure (or <code>?</code> if the structure is unnamed), the <code>=</code> sign, the type of the members and by <code>}</code><br></td></tr><tr align="left"><td valign="top">unions</td><td valign="top"><code>(</code> followed by the name of the structure (or <code>?</code> if the union is unnamed), the <code>=</code> sign, the type of the members followed by <code>)</code>   <br></td></tr></table>   <p>Here are some types and their encodings, as they are generated by thecompiler on an i386 machine:<br><p>   <p><table><tr align="left"><td valign="top">Objective-C type</td><td valign="top">Compiler encoding<br></td></tr><tr align="left"><td valign="top"><pre class="smallexample">     int a[10];     </pre></td><td valign="top"><code>[10i]</code><br></td></tr><tr align="left"><td valign="top"><pre class="smallexample">     struct {       int i;       float f[3];       int a:3;       int b:2;       char c;     }     </pre></td><td valign="top"><code>{?=i[3f]b128i3b131i2c}</code>   <br></td></tr></table><br><p>   <p>In addition to the types the compiler also encodes the typespecifiers.  The table below describes the encoding of the currentObjective-C type specifiers:<br><p>   <p><table><tr align="left"><td valign="top">Specifier</td><td valign="top">Encoding<br></td></tr><tr align="left"><td valign="top"><code>const</code></td><td valign="top"><code>r</code><br></td></tr><tr align="left"><td valign="top"><code>in</code></td><td valign="top"><code>n</code><br></td></tr><tr align="left"><td valign="top"><code>inout</code></td><td valign="top"><code>N</code><br></td></tr><tr align="left"><td valign="top"><code>out</code></td><td valign="top"><code>o</code><br></td></tr><tr align="left"><td valign="top"><code>bycopy</code></td><td valign="top"><code>O</code><br></td></tr><tr align="left"><td valign="top"><code>oneway</code></td><td valign="top"><code>V</code>   <br></td></tr></table><br><p>   <p>The type specifiers are encoded just before the type.  Unlike typeshowever, the type specifiers are only encoded when they appear in methodargument types.   </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -