Lines Matching refs:code
190 code. In the past, it has been abused as a general text processor. It
242 Source code character set processing in C and related languages is
268 @code{wchar_t} type, in the target machine's byte
271 @code{wchar_t} is enshrined in some system ABIs so we cannot fix
305 OSX) respectively. You may therefore safely copy source code written
332 incorrectly. Portable code should not rely on trigraphs being either
445 is equivalent to @code{@w{#define FOO 1020}}. All these tricks are
446 extremely confusing and should not be used in code intended to be
468 token. For instance, @code{a+++++b} is interpreted as
469 @code{@w{a ++ ++ + b}}, not as @code{@w{a ++ + ++ b}}, even though the
498 preprocessing keyword is @code{defined}. @xref{Defined}.
540 misinterpreted. For example, @code{0xE+12} is a preprocessing number
542 syntax error. It does not mean @code{@w{0xE + 12}}, which is what you
595 certainly reject source code containing ``other'' tokens. In ASCII, the
643 for arbitrary fragments of C code. The preprocessor will replace the
675 @code{foo} is defined as a macro expanding to @code{define}, that does
749 @table @code
759 directories used for @code{<@var{file}>}. You can prepend directories
765 recognized, and macro names are not expanded. Thus, @code{@w{#include
771 Thus, @code{@w{#include "x\n\\y"}} specifies a filename containing three
847 requested with @code{@w{#include <@var{file}>}} in:
858 GCC was configured to compile code for; often but not always the same as
881 GCC looks for headers requested with @code{@w{#include "@var{file}"}}
886 @code{@w{#include "types.h"}}, GCC looks for @file{types.h} first in
917 @cindex wrapper @code{#ifndef}
941 because @code{FILE_FOO_SEEN} is defined. The preprocessor will skip
955 The macro @code{FILE_FOO_SEEN} is called the @dfn{controlling macro} or
994 @code{SYSTEM_H} will be expanded, and the preprocessor will look for
996 originally. @code{SYSTEM_H} could be defined by your Makefile with a
1080 both directories contain @file{signal.h}. Ordinary @code{@w{#include
1082 file contains @code{@w{#include_next <signal.h>}}, it starts searching
1085 @samp{#include_next} does not distinguish between @code{<@var{file}>}
1086 and @code{"@var{file}"} inclusion, nor does it check that the file you
1103 Therefore, GCC gives code found in @dfn{system headers} special
1109 because of code in macros defined in system headers.
1126 There is also a directive, @code{@w{#pragma GCC system_header}}, which
1129 @samp{#pragma} in the file will not be affected. @code{@w{#pragma GCC
1133 get even more special treatment. GNU C++ considers code in headers
1134 found in those directories to be surrounded by an @code{@w{extern "C"}}
1141 A @dfn{macro} is a fragment of code which has been given a name.
1149 can be useful if you wish to hide a keyword such as @code{const} from an
1151 operator @code{defined} (@pxref{Defined}) can never be defined as a
1175 by a code fragment. It is called object-like because it looks like a
1176 data object in code that uses it. They are most commonly used to give
1190 defines a macro named @code{BUFFER_SIZE} as an abbreviation for the
1191 token @code{1024}. If somewhere after this @samp{#define} directive
1200 @code{BUFFER_SIZE}. The C compiler will see the same tokens as it would
1230 balance, and the body need not resemble valid C code. (If it does not,
1266 @code{TABLESIZE} is expanded first to produce @code{BUFSIZE}, then that
1267 macro is expanded to produce the final result, @code{1024}.
1269 Notice that @code{BUFSIZE} was not defined when @code{TABLESIZE} was
1270 defined. The @samp{#define} for @code{TABLESIZE} uses exactly the
1271 expansion you specify---in this case, @code{BUFSIZE}---and does not
1273 @emph{use} @code{TABLESIZE} is the result of its expansion scanned for
1276 This makes a difference if you change the definition of @code{BUFSIZE}
1277 at some point in the source file. @code{TABLESIZE}, defined as shown,
1278 will always expand using the definition of @code{BUFSIZE} that is
1289 Now @code{TABLESIZE} expands (in two stages) to @code{37}.
1324 Here the call to @code{foo()} will use the macro, but the function
1341 invocation. Since @code{lang_init} is an object-like macro, it does not
1392 passes two arguments to @code{macro}: @code{array[x = y} and @code{x +
1393 1]}. If you want to supply @code{array[x = y, x + 1]} as an argument,
1394 you can write it as @code{array[(x = y, x + 1)]}, which is equivalent C
1395 code.
1405 For example, @code{min (min (a, b), c)} is first expanded to
1427 preprocessor (but many macros will then expand to invalid code).
1430 Here are some silly examples using @code{min}:
1442 Whitespace is not a preprocessing token, so if a macro @code{foo} takes
1443 one argument, @code{@w{foo ()}} and @code{@w{foo ( )}} both supply it an
1492 The argument for @code{EXP} is substituted once, as-is, into the
1493 @code{if} statement, and once, stringified, into the argument to
1494 @code{fprintf}. If @code{x} were a macro, it would be expanded in the
1495 @code{if} statement, but not in the string.
1497 The @code{do} and @code{while (0)} are a kludge to make it possible to
1498 write @code{WARN_IF (@var{arg});}, which the resemblance of
1499 @code{WARN_IF} to a function would make C programmers want to do; see
1506 proper contents. Thus, stringifying @code{@w{p = "foo\n";}} results in
1534 @code{s} is stringified when it is used in @code{str}, so it is not
1535 macro-expanded first. But @code{s} is an ordinary argument to
1536 @code{xstr}, so it is completely macro-expanded before @code{xstr}
1538 @code{str} gets to its argument, it has already been macro-expanded.
1556 number and a name, such as @code{1.5} and @code{e3}) into a number.
1557 Also, multi-character operators such as @code{+=} can be formed by
1561 pasted together. For example, you cannot concatenate @code{x} with
1562 @code{+} in either order. If you try, the preprocessor issues a warning
1643 @code{@w{__VA_ARGS__}} in the macro body wherever it appears. Thus, we
1658 the variable argument than @code{@w{__VA_ARGS__}}. CPP permits
1661 The @code{eprintf} macro above could be written
1668 using this extension. You cannot use @code{@w{__VA_ARGS__}} and this
1672 macro. We could define @code{eprintf} like this, instead:
1708 and the variable argument is left out when the @code{eprintf} macro is
1727 C99 mandates that the only place the identifier @code{@w{__VA_ARGS__}}
1736 (@samp{args@dots{}}, not @samp{@dots{}} and @code{@w{__VA_ARGS__}}). If you are
1740 use only @code{@w{__VA_ARGS__}}.
1783 @table @code
1789 @code{"/usr/local/include/myheader.h"} is a possible expansion of this
1796 new line of source code.
1799 @code{__FILE__} and @code{__LINE__} are useful in generating an error
1811 An @samp{#include} directive changes the expansions of @code{__FILE__}
1812 and @code{__LINE__} to correspond to the included file. At the end of
1814 the @samp{#include} directive, the expansions of @code{__FILE__} and
1815 @code{__LINE__} revert to the values they had before the
1816 @samp{#include} (but @code{__LINE__} is then incremented by one as
1819 A @samp{#line} directive changes @code{__LINE__}, and may change
1820 @code{__FILE__} as well. @xref{Line Control}.
1822 C99 introduces @code{__func__}, and GCC has provided @code{__FUNCTION__}
1827 with @code{__FILE__} and @code{__LINE__}, though.
1829 @table @code
1834 characters and looks like @code{@w{"Feb 12 1996"}}. If the day of the
1838 (once per compilation) and @code{__DATE__} will expand to
1839 @code{@w{"??? ?? ????"}}.
1844 eight characters and looks like @code{"23:59:01"}.
1847 (once per compilation) and @code{__TIME__} will expand to
1848 @code{"??:??:??"}.
1860 @code{__STDC__} is normally 0, but is 1 if the user specifies strict
1863 @code{__STDC__} is always 1. This has been reported to cause problems;
1865 expect @code{__STDC__} to be either undefined or 1. @xref{Invocation}.
1869 constant of the form @code{@var{yyyy}@var{mm}L} where @var{yyyy} and
1872 @code{__STDC__}, this is not necessarily accurate for the entire
1875 The value @code{199409L} signifies the 1989 C standard as amended in
1876 1994, which is the current default; the value @code{199901L} signifies
1890 @code{__cplusplus} to test whether a header is compiled by a C compiler
1891 or a C++ compiler. This macro is similar to @code{__STDC_VERSION__}, in
1893 of the 1998 C++ standard will define this macro to @code{199711L}. The
1894 GNU C++ compiler is not yet fully conforming, so it uses @code{1}
1913 @table @code
1917 conjuction with the @code{##} operator, this provides a convenient means to
1919 @code{__COUNTER__} is not expanded prior to inclusion of precompiled headers
1928 example, GCC 3.2.1 will define @code{__GNUC__} to 3,
1929 @code{__GNUC_MINOR__} to 2, and @code{__GNUC_PATCHLEVEL__} to 1. These
1932 @code{__GNUC_PATCHLEVEL__} is new to GCC 3.0; it is also present in the
1938 you can simply test @code{__GNUC__}. If you need to write code
1972 testing @code{@w{(__GNUC__ && __cplusplus)}}.
2006 These macros describe the compilation mode. @code{__OPTIMIZE__} is
2007 defined in all optimizing compilations. @code{__OPTIMIZE_SIZE__} is
2009 @code{__NO_INLINE__} is defined if no functions will be inlined into
2020 GCC defines this macro if functions declared @code{inline} will be
2021 handled in GCC's traditional gnu89 mode. In this mode an @code{extern
2023 an @code{inline} function which is neither @code{extern} nor
2024 @code{static} will always be compiled as a standalone function.
2027 GCC defines this macro if functions declared @code{inline} will be
2029 @code{extern inline} function will always be compiled as a standalone
2030 externally visible function, and an @code{inline} function which is
2031 neither @code{extern} nor @code{static} will never be compiled as a
2034 If this macro is defined, GCC supports the @code{gnu_inline} function
2036 this and @code{__GNUC_GNU_INLINE__} was added in GCC 4.1.3. If
2038 @code{inline} functions will be compiled in gnu89 mode, and the
2039 @code{gnu_inline} function attribute will not be recognized.
2042 GCC defines this macro if and only if the data type @code{char} is
2048 Like @code{__CHAR_UNSIGNED__}, this macro is defined if and only if the
2049 data type @code{wchar_t} is unsigned and the front-end is in C++ mode.
2055 environments. For example, in the @code{m68k-aout} environment it
2056 expands to nothing, but in the @code{m68k-coff} environment it expands
2061 user labels (symbols visible to C code) in assembly. For example, in
2062 the @code{m68k-aout} environment it expands to an @samp{_}, but in the
2063 @code{m68k-coff} environment it expands to nothing.
2077 @code{size_t}, @code{ptrdiff_t}, @code{wchar_t}, @code{wint_t},
2078 @code{intmax_t}, and @code{uintmax_t}
2086 @code{char} data type. It exists to make the standard header given
2097 Defined to the maximum value of the @code{signed char}, @code{wchar_t},
2098 @code{signed short},
2099 @code{signed int}, @code{signed long}, @code{signed long long}, and
2100 @code{intmax_t} types
2117 mechanism based on @code{setjmp} and @code{longjmp} for exception
2126 general, user code should not need to make use of this macro; the
2133 is for a target where @code{long int} and pointer both use 64-bits and
2134 @code{int} uses 32-bit.
2152 hh:mm:ss form, year and looks like @code{@w{"Sun Sep 16 01:03:52 1973"}}.
2156 (once per compilation) and @code{__TIMESTAMP__} will expand to
2157 @code{@w{"??? ??? ?? ??:??:?? ????"}}.
2181 to find @code{unix} defined on Unix systems. For all such macros, GCC
2183 and the end. If @code{unix} is defined, @code{__unix__} will be defined
2185 @code{_mips} is @code{__mips__}.
2195 encourage you to correct older code to use the parallel macros whenever
2219 @item @code{and} @tab @code{&&}
2220 @item @code{and_eq} @tab @code{&=}
2221 @item @code{bitand} @tab @code{&}
2222 @item @code{bitor} @tab @code{|}
2223 @item @code{compl} @tab @code{~}
2224 @item @code{not} @tab @code{!}
2225 @item @code{not_eq} @tab @code{!=}
2226 @item @code{or} @tab @code{||}
2227 @item @code{or_eq} @tab @code{|=}
2228 @item @code{xor} @tab @code{^}
2229 @item @code{xor_eq} @tab @code{^=}
2306 @samp{printf} had changed to be a function-like macro, and their code
2405 to compute how many @code{int} objects are needed to hold a certain
2406 number of @code{char} objects.) Then suppose it is used as follows:
2438 Unintended grouping can result in another way. Consider @code{sizeof
2440 compute the size of the type of @code{ceil_div (1, 2)}, but in fact it
2449 precedence rules have put the division outside the @code{sizeof} when it
2453 Here, then, is the recommended way to define @code{ceil_div}:
2465 pointer (the argument @code{p} says where to find it) across whitespace
2478 be a single logical line, so that it resembles the way such code would
2481 A call to this macro might be @code{SKIP_SPACES (p, lim)}. Strictly
2486 @code{SKIP_SPACES (p, lim);}
2488 This can cause trouble before @code{else} statements, because the
2499 statement---in between the @code{if} condition and the @code{else}
2500 makes invalid C code.
2502 The definition of the macro @code{SKIP_SPACES} can be altered to solve
2503 this problem, using a @code{do @dots{} while} statement. Here is how:
2514 Now @code{SKIP_SPACES (p, lim);} expands into
2522 generate no extra code for it.
2529 Many C programs define a macro @code{min}, for ``minimum'', like this:
2550 where @code{x + y} has been substituted for @code{X} and @code{foo (z)}
2551 for @code{Y}.
2553 The function @code{foo} is used only once in the statement as it appears
2554 in the program, but the expression @code{foo (z)} has been substituted
2555 twice into the macro expansion. As a result, @code{foo} might be called
2558 intended. We say that @code{min} is an @dfn{unsafe} macro.
2560 The best solution to this problem is to define @code{min} in a way that
2561 computes the value of @code{foo (z)} only once. The C language offers
2580 careful when @emph{using} the macro @code{min}. For example, you can
2581 calculate the value of @code{foo (z)}, save it in a variable, and use
2582 that variable in @code{min}:
2596 (where we assume that @code{foo} returns type @code{int}).
2614 where @code{foo} is also a variable in your program.
2616 Following the ordinary rules, each reference to @code{foo} will expand
2617 into @code{(4 + foo)}; then this will be rescanned and will expand into
2618 @code{(4 + (4 + foo))}; and so on until the computer runs out of memory.
2621 @code{(4 + foo)}. Therefore, this macro definition has the possibly
2622 useful effect of causing the program to add 4 to the value of @code{foo}
2623 wherever @code{foo} is referred to.
2626 person reading the program who sees that @code{foo} is a variable will
2628 identifier @code{foo} in the program and think its value should be that
2629 of the variable @code{foo}, whereas in fact the value is four greater.
2639 then the macro @code{EPERM} expands to @code{EPERM}. Effectively, it is
2642 want to define numeric constants with an @code{enum}, but have
2645 If a macro @code{x} expands to use a macro @code{y}, and the expansion of
2646 @code{y} refers to the macro @code{x}, that is an @dfn{indirect
2647 self-reference} of @code{x}. @code{x} is not expanded in this case
2656 then @code{x} and @code{y} expand as follows:
2709 contains a call to that very macro. For example, if @code{f} is a macro
2710 that expects one argument, @code{f (f (1))} is a nested pair of calls to
2711 @code{f}. The desired expansion is made by expanding @code{f (1)} and
2712 substituting that into the definition of @code{f}. The prescan causes
2713 the expected result to happen. Without the prescan, @code{f (1)} itself
2714 would be substituted as an argument, and the inner use of @code{f} would
2734 then @code{AFTERX(BUFSIZE)} expands to @code{X_BUFSIZE}, and
2735 @code{XAFTERX(BUFSIZE)} expands to @code{X_1024}. (Not to
2736 @code{X_TABLESIZE}. Prescan always does a complete expansion.)
2750 We would like @code{bar(foo)} to turn into @code{(1 + (foo))}, which
2751 would then turn into @code{(1 + (a,b))}. Instead, @code{bar(foo)}
2752 expands into @code{lose(a,b)}, and you get an error because @code{lose}
2763 The extra pair of parentheses prevents the comma in @code{foo}'s
2789 The syntax error triggered by the tokens @code{syntax error} results in
2791 even though the problematic code comes from line five.
2800 select whether or not to include a chunk of code in the final token
2803 simultaneously using the special @code{defined} operator.
2805 A conditional in the C preprocessor resembles in some ways an @code{if}
2807 them. The condition in an @code{if} statement is tested during the
2812 code to be included in the program depending on the situation at the
2816 do test @code{if} statements when a program is compiled, if their
2817 conditions are known not to vary at run time, and eliminate code which
2819 you may find that your program is more readable if you use @code{if}
2821 course, you can only use this to exclude code, not type definitions or
2822 other preprocessing directives, and you can only do it if the code
2825 GCC version 3 eliminates this kind of never-executed code even when
2841 A program may need to use different code depending on the machine or
2842 operating system it is to run on. In some cases the code for one
2846 executing the invalid code. Its mere presence will cause the compiler
2848 code can be effectively excised from the program when it is not valid.
2857 A conditional whose condition is always false is one way to exclude code
2921 @samp{#endif} without enclosing it in a comment. This is invalid code
2926 Sometimes you wish to use some code if a macro is @emph{not} defined.
2928 One common use of @samp{#ifndef} is to include code only the first
2938 code specially tuned for a particular machine.
2987 code.
2992 operations (@code{&&} and @code{||}). The latter two obey the usual
3000 Uses of the @code{defined} operator, which lets you check whether macros
3005 number zero. This allows you to write @code{@w{#if MACRO}} instead of
3006 @code{@w{#ifdef MACRO}}, if you know that MACRO, when defined, will
3016 Therefore, @code{sizeof} operators are not recognized in @samp{#if}, and
3017 neither are @code{enum} constants. They will be taken as identifiers
3019 @code{sizeof}, this is likely to cause the expression to be invalid.
3032 @cindex @code{defined}
3033 The special operator @code{defined} is used in @samp{#if} and
3035 macro. @code{defined @var{name}} and @code{defined (@var{name})} are
3037 the current point in the program, and 0 otherwise. Thus, @code{@w{#if
3038 defined MACRO}} is precisely equivalent to @code{@w{#ifdef MACRO}}.
3040 @code{defined} is useful when you wish to test more than one macro for
3048 would succeed if either of the names @code{__vax__} or
3049 @code{__ns16000__} is defined as a macro.
3058 can generally be simplified to just @code{@w{#if BUFSIZE >= 1024}},
3059 since if @code{BUFSIZE} is not defined, it will be interpreted as having
3062 If the @code{defined} operator appears as a result of a macro expansion,
3064 genuine @code{defined} operator and evaluates it normally. It will warn
3065 wherever your code uses this feature if you use the command-line option
3142 @cindex commenting out code
3145 code around for future reference, you often cannot simply comment it
3147 code will end the commenting-out. The probable result is a flood of
3151 instead. For instance, put @code{#if 0} before the deleted code and
3152 @code{#endif} after it. This works even if the code being turned
3156 Some people use @code{#ifdef notdef} instead. This is risky, because
3157 @code{notdef} might be accidentally defined as a macro, and then the
3158 conditional would succeed. @code{#if 0} can be counted on to fail.
3160 Do not use @code{#if 0} for comments which are not C code. Use a real
3161 comment, instead. The interior of @code{#if 0} must consist of complete
3164 apostrophes). These confuse @code{#if 0}. They don't confuse
3220 code where each token came from. Presently, this is just the file name
3225 If you write a program which generates source code, such as the
3231 symbolic debuggers to be able to refer to @code{bison}'s input file.
3240 @table @code
3264 @samp{#line} directives alter the results of the @code{__FILE__} and
3265 @code{__LINE__} predefined macros from that point on. @xref{Standard
3307 language, such as @code{__attribute__}, for this purpose. However, GCC
3312 @code{GCC} prefix. This is in line with the @code{STDC} prefix on all
3315 @code{GCC} prefix, but that usage is deprecated. Some older pragmas are
3317 @code{GCC} prefix. @xref{Obsolete Features}.
3319 @cindex @code{_Pragma}
3320 C99 introduces the @code{@w{_Pragma}} operator. This feature addresses a
3322 produced as the result of macro expansion. @code{@w{_Pragma}} is an
3323 operator, much like @code{sizeof} or @code{defined}, and can be embedded
3326 Its syntax is @code{@w{_Pragma (@var{string-literal})}}, where
3338 has the same effect as @code{#pragma GCC dependency "parse.y"}. The
3346 The standard is unclear on where a @code{_Pragma} operator can appear.
3356 @ftable @code
3358 @code{#pragma GCC dependency} allows you to check the relative dates of
3375 @code{#pragma GCC poison} is followed by a list of identifiers to
3404 This pragma takes no arguments. It causes the rest of the code in the
3488 wrapped in an implicit @code{extern "C"} block.
3554 quotes, and also by an initial @samp{<} in a @code{#include}
3590 However, all preprocessing directives other than @code{#define}
3771 instance, @code{UINT_MAX} may well be defined as @code{4294967295U}, but
3772 you will not be warned if you use @code{UINT_MAX}.
3857 bit-pattern is given type @code{int}, and is therefore signed,
3860 characters in the constant than would fit in the target @code{int} the
3864 For example, @code{'ab'} for a target with an 8-bit @code{char} would be
3866 'b')}}, and @code{'\234a'} as @w{@samp{(int) ((unsigned char) '\234' *
3903 is allocated with @code{malloc} or equivalent. The actual limit will
3937 We allow @code{USHRT_MAX}, which is no smaller than 65,535. The minimum
3960 compatibility with older programs. We discourage their use in new code.
3997 redefinition.) Thus, @code{(x + y)} is different from @code{(x+y)} but
3998 equivalent to @code{@w{( x + y )}}. Parentheses do not nest inside an
4003 conditional succeeds if either @code{vax} or @code{ns16000} has been
4004 asserted as an answer for @code{machine}.
4092 at the same time as @samp{##}. You should therefore not write any code