📄 tcc-doc.html
字号:
<DT><SAMP>`-Wunsupported'</SAMP><DD>Warn about unsupported GCC features that are ignored by TCC.<P><DT><SAMP>`-Wwrite-strings'</SAMP><DD>Make string constants be of type <CODE>const char *</CODE> instead of <CODE>char*</CODE>.<P><DT><SAMP>`-Werror'</SAMP><DD>Abort compilation if warnings are issued.<P><DT><SAMP>`-Wall'</SAMP><DD>Activate all warnings, except <SAMP>`-Werror'</SAMP>, <SAMP>`-Wunusupported'</SAMP> and<SAMP>`-Wwrite-strings'</SAMP>.<P></DL><P>Linker options:</P><P><DL COMPACT><DT><SAMP>`-Ldir'</SAMP><DD>Specify an additional static library path for the <SAMP>`-l'</SAMP> option. Thedefault library paths are <TT>`/usr/local/lib'</TT>, <TT>`/usr/lib'</TT> and <TT>`/lib'</TT>.<P><DT><SAMP>`-lxxx'</SAMP><DD>Link your program with dynamic library libxxx.so or static librarylibxxx.a. The library is searched in the paths specified by the<SAMP>`-L'</SAMP> option.<P><DT><SAMP>`-shared'</SAMP><DD>Generate a shared library instead of an executable (<SAMP>`-o'</SAMP> optionmust also be given).<P><DT><SAMP>`-static'</SAMP><DD>Generate a statically linked executable (default is a shared linkedexecutable) (<SAMP>`-o'</SAMP> option must also be given).<P><DT><SAMP>`-rdynamic'</SAMP><DD>Export global symbols to the dynamic linker. It is useful when a libraryopened with <CODE>dlopen()</CODE> needs to access executable symbols.<P><DT><SAMP>`-r'</SAMP><DD>Generate an object file combining all input files (<SAMP>`-o'</SAMP> option mustalso be given).<P><DT><SAMP>`-Wl,-Ttext,address'</SAMP><DD>Set the start of the .text section to <VAR>address</VAR>.<P><DT><SAMP>`-Wl,--oformat,fmt'</SAMP><DD>Use <VAR>fmt</VAR> as output format. The supported output formats are:<DL COMPACT><DT><CODE>elf32-i386</CODE><DD>ELF output format (default)<DT><CODE>binary</CODE><DD>Binary image (only for executable output)<DT><CODE>coff</CODE><DD>COFF output format (only for executable output for TMS320C67xx target)</DL><P></DL><P>Debugger options:</P><P><DL COMPACT><DT><SAMP>`-g'</SAMP><DD>Generate run time debug information so that you get clear run timeerror messages: <CODE> test.c:68: in function 'test5()': dereferencinginvalid pointer</CODE> instead of the laconic <CODE>Segmentationfault</CODE>.<P><DT><SAMP>`-b'</SAMP><DD>Generate additional support code to checkmemory allocations and array/pointer bounds. <SAMP>`-g'</SAMP> is implied. Notethat the generated code is slower and bigger in this case.<P><DT><SAMP>`-bt N'</SAMP><DD>Display N callers in stack traces. This is useful with <SAMP>`-g'</SAMP> or<SAMP>`-b'</SAMP>.<P></DL><P>Note: GCC options <SAMP>`-Ox'</SAMP>, <SAMP>`-fx'</SAMP> and <SAMP>`-mx'</SAMP> areignored.</P><P><HR SIZE="6"><A NAME="SEC5"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC4"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC6"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H1> 3. C language support </H1><!--docid::SEC5::--><P><HR SIZE="6"><A NAME="SEC6"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC5"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC7"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 3.1 ANSI C </H2><!--docid::SEC6::--><P>TCC implements all the ANSI C standard, including structure bit fieldsand floating point numbers (<CODE>long double</CODE>, <CODE>double</CODE>, and<CODE>float</CODE> fully supported).</P><P><HR SIZE="6"><A NAME="SEC7"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC6"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC8"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 3.2 ISOC99 extensions </H2><!--docid::SEC7::--><P>TCC implements many features of the new C standard: ISO C99. Currentlymissing items are: complex and imaginary numbers and variable lengtharrays.</P><P>Currently implemented ISOC99 features:</P><P><UL><LI>64 bit <CODE>long long</CODE> types are fully supported.<P><LI>The boolean type <CODE>_Bool</CODE> is supported.<P><LI><CODE>__func__</CODE> is a string variable containing the currentfunction name.<P><LI>Variadic macros: <CODE>__VA_ARGS__</CODE> can be used for function-like macros:<TABLE><tr><td> </td><td class=example><pre> #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__)</pre></td></tr></table><P><CODE>dprintf</CODE> can then be used with a variable number of parameters.</P><P><LI>Declarations can appear anywhere in a block (as in C++).<P><LI>Array and struct/union elements can be initialized in any order by using designators:<TABLE><tr><td> </td><td class=example><pre> struct { int x, y; } st[10] = { [0].x = 1, [0].y = 2 }; int tab[10] = { 1, 2, [5] = 5, [9] = 9};</pre></td></tr></table> <LI>Compound initializers are supported:<TABLE><tr><td> </td><td class=example><pre> int *p = (int []){ 1, 2, 3 };</pre></td></tr></table>to initialize a pointer pointing to an initialized array. The sameworks for structures and strings.<P><LI>Hexadecimal floating point constants are supported:<TABLE><tr><td> </td><td class=example><pre> double d = 0x1234p10;</pre></td></tr></table><P>is the same as writing <TABLE><tr><td> </td><td class=example><pre> double d = 4771840.0;</pre></td></tr></table></P><P><LI><CODE>inline</CODE> keyword is ignored.<P><LI><CODE>restrict</CODE> keyword is ignored.</UL><P><HR SIZE="6"><A NAME="SEC8"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC7"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC9"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC1">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC36">Index</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="tcc-doc.html#SEC_About"> ? </A>]</TD></TR></TABLE><H2> 3.3 GNU C extensions </H2><!--docid::SEC8::--><P>TCC implements some GNU C extensions:</P><P><UL><LI>array designators can be used without '=':<TABLE><tr><td> </td><td class=example><pre> int a[10] = { [0] 1, [5] 2, 3, 4 };</pre></td></tr></table><P><LI>Structure field designators can be a label:<TABLE><tr><td> </td><td class=example><pre> struct { int x, y; } st = { x: 1, y: 1};</pre></td></tr></table>instead of<TABLE><tr><td> </td><td class=example><pre> struct { int x, y; } st = { .x = 1, .y = 1};</pre></td></tr></table><P><LI><CODE>\e</CODE> is ASCII character 27.<P><LI>case ranges : ranges can be used in <CODE>case</CODE>s:<TABLE><tr><td> </td><td class=example><pre> switch(a) { case 1 <small>...</small> 9: printf("range 1 to 9\n"); break; default: printf("unexpected\n"); break; }</pre></td></tr></table><P><A NAME="IDX1"></A><A NAME="IDX2"></A><A NAME="IDX3"></A><A NAME="IDX4"></A><A NAME="IDX5"></A><A NAME="IDX6"></A><A NAME="IDX7"></A><A NAME="IDX8"></A></P><P><LI>The keyword <CODE>__attribute__</CODE> is handled to specify variable orfunction attributes. The following attributes are supported:<UL><LI><CODE>aligned(n)</CODE>: align a variable or a structure field to n bytes(must be a power of two).<P><LI><CODE>packed</CODE>: force alignment of a variable or a structure field to 1.<P><LI><CODE>section(name)</CODE>: generate function or data in assembly sectionname (name is a string containing the section name) instead of the defaultsection.<P><LI><CODE>unused</CODE>: specify that the variable or the function is unused.<P><LI><CODE>cdecl</CODE>: use standard C calling convention (default).<P><LI><CODE>stdcall</CODE>: use Pascal-like calling convention.<P><LI><CODE>regparm(n)</CODE>: use fast i386 calling convention. <VAR>n</VAR> must bebetween 1 and 3. The first <VAR>n</VAR> function parameters are respectively put inregisters <CODE>%eax</CODE>, <CODE>%edx</CODE> and <CODE>%ecx</CODE>.<P><LI><CODE>dllexport</CODE>: export function from dll/executable (win32 only)<P></UL><P>Here are some examples:<TABLE><tr><td> </td><td class=example><pre> int a __attribute__ ((aligned(8), section(".mysection")));</pre></td></tr></table></P><P>align variable <CODE>a</CODE> to 8 bytes and put it in section <CODE>.mysection</CODE>.</P><P><TABLE><tr><td> </td><td class=example><pre> int my_add(int a, int b) __attribute__ ((section(".mycodesection"))) { return a + b; }</pre></td></tr></table></P><P>generate function <CODE>my_add</CODE> in section <CODE>.mycodesection</CODE>.</P><P><LI>GNU style variadic macros:<TABLE><tr><td> </td><td class=example><pre> #define dprintf(fmt, args<small>...</small>) printf(fmt, ## args) dprintf("no arg\n"); dprintf("one arg %d\n", 1);</pre></td></tr></table><P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -