| Chris Lattner | cf17d9d | 2009-04-20 04:23:09 +0000 | [diff] [blame^] | 1 | <html> | 
 | 2 | <head> | 
 | 3 | <title>Clang Compiler User's Manual</title> | 
 | 4 | <link type="text/css" rel="stylesheet" href="../menu.css" /> | 
 | 5 | <link type="text/css" rel="stylesheet" href="../content.css" /> | 
 | 6 | <style type="text/css"> | 
 | 7 | td { | 
 | 8 | 	vertical-align: top; | 
 | 9 | } | 
 | 10 | </style> | 
 | 11 | </head> | 
 | 12 | <body> | 
 | 13 |  | 
 | 14 | <!--#include virtual="../menu.html.incl"--> | 
 | 15 |  | 
 | 16 | <div id="content"> | 
 | 17 |  | 
 | 18 | <h1>Clang Compiler User's Manual</h1> | 
 | 19 |  | 
 | 20 | <ul> | 
 | 21 | <li><a href="#intro">Introduction</a> | 
 | 22 |   <ul> | 
 | 23 |   <li><a href="#terminology">Terminology</a></li> | 
 | 24 |   <li><a href="#basicusage">Basic Usage</a></li> | 
 | 25 |   </ul> | 
 | 26 | </li> | 
 | 27 | <li><a href="#commandline">Command Line Options</a></li> | 
 | 28 | <li><a href="#general_features">Language and Target-Independent Features</a> | 
 | 29 |  <ul> | 
 | 30 |   <li><a href="#diagnostics">Controlling Errors and Warnings</a></li> | 
 | 31 |   <li><a href="#precompiledheaders">Precompiled Headers</a></li> | 
 | 32 |   </ul> | 
 | 33 | </li> | 
 | 34 | <li><a href="#c">C Language Features</a> | 
 | 35 |   <ul> | 
 | 36 | <!--  <li><a href="#pragmas">Pragmas Supported</a></li> --> | 
 | 37 |   <li><a href="#c_extensions">C Extensions Supported</a></li> | 
 | 38 |   <li><a href="#c_incompatibilities">Intentional Incompatibilities with | 
 | 39 |       GCC</a></li> | 
 | 40 |   </ul> | 
 | 41 | </li> | 
 | 42 | <li><a href="#objc">Objective-C Language Features</a> | 
 | 43 |   <ul> | 
 | 44 |   <li><a href="#objc_incompatibilities">Intentional Incompatibilities with | 
 | 45 |       GCC</a></li> | 
 | 46 |   </ul> | 
 | 47 | </li> | 
 | 48 | <li><a href="#cxx">C++ Language Features</a> | 
 | 49 |   <ul> | 
 | 50 |   <li>...</li> | 
 | 51 |   </ul> | 
 | 52 | </li> | 
 | 53 | <li><a href="#objcxx">Objective C++ Language Features</a> | 
 | 54 |   <ul> | 
 | 55 |   <li>...</li> | 
 | 56 |   </ul> | 
 | 57 | </li> | 
 | 58 | <li><a href="#target_features">Target-Specific Features and Limitations</a> | 
 | 59 |   <ul> | 
 | 60 |   <li><a href="#target_arch">CPU Architectures Features and Limitations</a> | 
 | 61 |     <ul> | 
 | 62 |     <li><a href="#target_arch_x86">X86</a></li> | 
 | 63 |     <li>PPC</li> | 
 | 64 |     <li>ARM</li> | 
 | 65 |     </ul> | 
 | 66 |   </li> | 
 | 67 |   <li><a href="#target_os">Operating System Features and Limitations</a> | 
 | 68 |     <ul> | 
 | 69 |     <li><a href="#target_os_darwin">Darwin (Mac OS/X)</a></li> | 
 | 70 |     <li>Linux, etc.</li> | 
 | 71 |     </ul> | 
 | 72 |    | 
 | 73 |   </li> | 
 | 74 |   </ul> | 
 | 75 | </li> | 
 | 76 | </ul> | 
 | 77 |  | 
 | 78 |  | 
 | 79 | <!-- ======================================================================= --> | 
 | 80 | <h2 id="intro">Introduction</h2> | 
 | 81 | <!-- ======================================================================= --> | 
 | 82 |  | 
 | 83 | <p>The Clang Compiler is an open-source compiler for the C family of programming | 
 | 84 | languages, aiming to be the best in class implementation of these languages. | 
 | 85 | Clang builds on the LLVM optimizer and code generator, allowing it to provide | 
 | 86 | high-quality optimization and code generation support for many targets.  For | 
 | 87 | more general information, please see the <a href="http://clang.llvm.org">Clang | 
 | 88 | Web Site</a> or the <a href="http://llvm.org">LLVM Web Site</a>.</p> | 
 | 89 |  | 
 | 90 | <p>This document describes important notes about using Clang as a compiler for | 
 | 91 | an end-user, documenting the supported features, command line options, etc.  If | 
 | 92 | you are interested in using Clang to build a tool that processes code, please | 
 | 93 | see <a href="InternalsManual.html">the Clang Internals Manual</a>.  If you are | 
 | 94 | interested in the <a href="http://clang.llvm.org/StaticAnalysis.html">Clang | 
 | 95 | Static Analyzer</a>, please see its web page.</p> | 
 | 96 |  | 
 | 97 | <p>Clang is designed to support the C family of programming languages, which | 
 | 98 | includes <a href="#c">C</a>, <a href="#objc">Objective-C</a>, <a | 
 | 99 | href="#cxx">C++</a>, and <a href="#objcxx">Objective-C++</a> as well as many | 
 | 100 | dialects of those.  For language-specific information, please see the | 
 | 101 | corresponding language specific section:</p> | 
 | 102 |  | 
 | 103 | <ul> | 
 | 104 | <li><a href="#c">C Language</a>: K&R C, ANSI C89, ISO C90, ISO C94 | 
 | 105 |     (C89+AMD1), ISO C99 (+TC1, TC2, TC3). </li> | 
 | 106 | <li><a href="#objc">Objective-C Language</a>: ObjC 1, ObjC 2, ObjC 2.1, plus | 
 | 107 |     variants depending on base language.</li> | 
 | 108 | <li><a href="#cxx">C++ Language Features</a></li> | 
 | 109 | <li><a href="#objcxx">Objective C++ Language</a></li> | 
 | 110 | </ul> | 
 | 111 |  | 
 | 112 | <p>In addition to these base languages and their dialects, Clang supports a | 
 | 113 | broad variety of language extensions, which are documented in the corresponding | 
 | 114 | language section.  These extensions are provided to be compatible with the GCC, | 
 | 115 | Microsoft, and other popular compilers as well as to improve functionality | 
 | 116 | through Clang-specific features.  The Clang driver and language features are | 
 | 117 | intentionally designed to be as compatible with the GNU GCC compiler as | 
 | 118 | reasonably possible, easing migration from GCC to Clang.  In most cases, code | 
 | 119 | "just works".</p> | 
 | 120 |  | 
 | 121 | <p>In addition to language specific features, Clang has a variety of features | 
 | 122 | that depend on what CPU architecture or operating system is being compiled for. | 
 | 123 | Please see the <a href="target_features">Target-Specific Features and | 
 | 124 | Limitations</a> section for more details.</p> | 
 | 125 |  | 
 | 126 | <p>The rest of the introduction introduces some basic <a | 
 | 127 | href="#terminology">compiler terminology</a> that is used throughout this manual | 
 | 128 | and contains a basic <a href="#basicusage">introduction to using Clang</a> | 
 | 129 | as a command line compiler.</p> | 
 | 130 |  | 
 | 131 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 132 | <h3 id="terminology">Terminology</h3> | 
 | 133 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 134 |  | 
 | 135 | <p>Front end, parser, backend, preprocessor, undefined behavior, diagnostic, | 
 | 136 |  optimizer</p> | 
 | 137 |  | 
 | 138 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 139 | <h3 id="basicusage">Basic Usage</h3> | 
 | 140 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 141 |  | 
 | 142 | <p>Intro to how to use a C compiler for newbies.</p> | 
 | 143 | <p> | 
 | 144 | compile + link | 
 | 145 |  | 
 | 146 | compile then link | 
 | 147 |  | 
 | 148 | debug info | 
 | 149 |  | 
 | 150 | enabling optimizations | 
 | 151 |  | 
 | 152 | picking a language to use, defaults to C99 by default.  Autosenses based on | 
 | 153 | extension. | 
 | 154 |  | 
 | 155 | using a makefile | 
 | 156 | </p> | 
 | 157 |  | 
 | 158 |  | 
 | 159 | <!-- ======================================================================= --> | 
 | 160 | <h2 id="commandline">Command Line Options</h2> | 
 | 161 | <!-- ======================================================================= --> | 
 | 162 |  | 
 | 163 | <p> | 
 | 164 | This section is generally an index into other sections.  It does not go into | 
 | 165 | depth on most.  However, the first part introduces the language selection and | 
 | 166 | other high level options like -c, -g, etc. | 
 | 167 | </p> | 
 | 168 |  | 
 | 169 | <!-- ======================================================================= --> | 
 | 170 | <h2 id="general_features">Language and Target-Independent Features</h2> | 
 | 171 | <!-- ======================================================================= --> | 
 | 172 |  | 
 | 173 |  | 
 | 174 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 175 | <h3 id="diagnostics">Controlling Errors and Warnings</h3> | 
 | 176 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 177 |  | 
 | 178 |  | 
 | 179 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 180 | <h3 id="precompiledheaders">Precompiled Headers</h3> | 
 | 181 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 182 |  | 
 | 183 |  | 
 | 184 |  | 
 | 185 | <!-- ======================================================================= --> | 
 | 186 | <h2 id="c">C Language Features</h2> | 
 | 187 | <!-- ======================================================================= --> | 
 | 188 |  | 
 | 189 |  | 
 | 190 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 191 | <h3 id="c_incompatibilities">Intentional Incompatibilities with GCC</h3> | 
 | 192 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 193 |  | 
 | 194 | <p>No VLAs in structs.</p> | 
 | 195 |  | 
 | 196 |  | 
 | 197 |  | 
 | 198 |  | 
 | 199 | <!-- ======================================================================= --> | 
 | 200 | <h2 id="objc">Objective-C Language Features</h2> | 
 | 201 | <!-- ======================================================================= --> | 
 | 202 |  | 
 | 203 |  | 
 | 204 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 205 | <h3 id="objc_incompatibilities">Intentional Incompatibilities with GCC</h3> | 
 | 206 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 207 |  | 
 | 208 | <p>No cast of super, no lvalue casts.</p> | 
 | 209 |  | 
 | 210 |  | 
 | 211 |  | 
 | 212 | <!-- ======================================================================= --> | 
 | 213 | <h2 id="cxx">C++ Language Features</h2> | 
 | 214 | <!-- ======================================================================= --> | 
 | 215 |  | 
 | 216 | <p>At this point, Clang C++ is not generally useful.  However, Clang C++ support | 
 | 217 | is under active development and is progressing rapidly.  Please see the <a | 
 | 218 | href="http://clang.llvm.org/cxx_status.html">C++ Status</a> page for details or | 
 | 219 | ask on the mailing list about how you can help.</p> | 
 | 220 |  | 
 | 221 | <p>Note that the clang driver will refuse to even try to use clang to compile | 
 | 222 | C++ code unless you pass the <tt>-ccc-clang-cxx</tt> option to the driver.  If | 
 | 223 | you really want to play with Clang's C++ support, please pass that flag. </p> | 
 | 224 |   | 
 | 225 | <!-- ======================================================================= --> | 
 | 226 | <h2 id="objcxx">Objective C++ Language Features</h2> | 
 | 227 | <!-- ======================================================================= --> | 
 | 228 |  | 
 | 229 | <p>At this point, Clang C++ support is not generally useful (and therefore, | 
 | 230 | neither is Objective-C++).  Please see the <a href="#cxx">C++ section</a> for | 
 | 231 | more information.</p> | 
 | 232 |  | 
 | 233 | <!-- ======================================================================= --> | 
 | 234 | <h2 id="target_features">Target-Specific Features and Limitations</h2> | 
 | 235 | <!-- ======================================================================= --> | 
 | 236 |  | 
 | 237 |  | 
 | 238 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 239 | <h3 id="target_arch">CPU Architectures Features and Limitations</h3> | 
 | 240 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 241 |  | 
 | 242 | <!-- ======================== --> | 
 | 243 | <h4 id="target_arch_x86">X86</h4> | 
 | 244 | <!-- ======================== --> | 
 | 245 |  | 
 | 246 |  | 
 | 247 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 248 | <h3 id="target_os">Operating System Features and Limitations</h3> | 
 | 249 | <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --> | 
 | 250 |  | 
 | 251 | <!-- ======================================= --> | 
 | 252 | <h4 id="target_os_darwin">Darwin (Mac OS/X)</h4> | 
 | 253 | <!-- ======================================= --> | 
 | 254 |  | 
 | 255 | <p>No __thread support, 64-bit ObjC support requires SL tools.</p> | 
 | 256 |  | 
 | 257 | </div> | 
 | 258 | </body> | 
 | 259 | </html> |