c standard: ansi c iso c gun c {-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 1702364
  • 博文数量: 143
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1462
  • 用 户 组: 普通用户
  • 注册时间: 2016-08-23 11:14
文章分类

(143)

  • (2)
  • (4)
  • (1)
  • (7)
  • (1)
  • (16)
  • (1)
  • (1)
  • (12)
  • (4)
  • (36)
  • (1)
  • (5)
  • (16)
  • (13)
  • (2)
  • (0)
  • (1)
  • (6)
  • (1)
  • (2)
  • (7)
  • (4)
  • (0)
文章存档

(3)

(13)

(21)

(8)

(28)

(7)

(63)

我的朋友
最近访客
相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: linux

2020-09-17 19:18:01

选自: gcc-arm-none-eabi/info/gcc.info
点击(此处)折叠或打开
  1. * gcc: (gcc). the gnu compiler collection. ---"(gnu tools for arm embedded processors)"

  2. 2.1 c language
  3. ==============
  4.  gcc supports three versions of the c standard, although support for the most recent version is not yet complete.

  5.  the original ansi c standard (x3.159-1989) was ratified in 1989 and published in 1990. this standard was ratified as an iso standard (iso/iec 9899:1990) later in 1990. there were no technical differences between these publications, although the sections of the ansi standard were renumbered and became clauses in the iso standard. this standard, in both its forms, is commonly known as "c89", or occasionally as "c90", from the dates of ratification. the ansi standard, but not the iso standard, also came with a rationale document. to select this standard in gcc, use one of the options `-ansi', `-std=c90' or `-std=iso9899:1990'; to obtain all the diagnostics required by the standard, you should also specify `-pedantic' (or `-pedantic-errors' if you want them to be errors rather than warnings). *note options controlling c dialect: c dialect options.
  6.  errors in the 1990 iso c standard were corrected in two technical corrigenda published in 1994 and 1996. gcc does not support the uncorrected version.

  7.  an amendment to the 1990 standard was published in 1995. this amendment added digraphs and `__stdc_version__' to the language, but otherwise concerned the library. this amendment is commonly known as "amd1"; the amended standard is sometimes known as "c94" or "c95". to select this standard in gcc, use the option `-std=iso9899:199409' (with, as for other standard versions, `-pedantic' to receive all required diagnostics).

  8.  a new edition of the iso c standard was published in 1999 as iso/iec 9899:1999, and is commonly known as "c99". gcc has incomplete support for this standard version; see `http://gcc.gnu.org/c99status.html' for details. to select this standard, use `-std=c99' or `-std=iso9899:1999'. (while in development, drafts of this standard version were referred to as "c9x".)
  9.  errors in the 1999 iso c standard were corrected in three technical corrigenda published in 2001, 2004 and 2007. gcc does not support the uncorrected version.

  10.  a fourth version of the c standard, known as "c11", was published in 2011 as iso/iec 9899:2011. gcc has limited incomplete support for parts of this standard, enabled with `-std=c11' or `-std=iso9899:2011'. (while in development, drafts of this standard version were referred to as "c1x".)


  11.  by default, gcc provides some extensions to the c language that on rare occasions conflict with the c standard. *note extensions to the c language family: c extensions. use of the `-std' options listed above will disable these extensions where they conflict with the c standard version selected. you may also select an extended version of the c language explicitly with `-std=gnu90' (for c90 with gnu extensions), `-std=gnu99' (for c99 with gnu extensions) or `-std=gnu11' (for c11 with gnu extensions). the default, if no c language dialect options are given, is `-std=gnu90'; this will change to `-std=gnu99' or `-std=gnu11' in some future release when the c99 or c11 support is complete. some features that are part of the c99 standard are accepted as extensions in c90 mode, and some features that are part of the c11 standard are accepted as extensions in c90 and c99 modes.


  12.  gcc does not provide the library facilities required only of hosted implementations, nor yet all the facilities required by c99 of freestanding implementations; to use the facilities of a hosted environment, you will need to find them elsewhere (for example, in the gnu c library). *note standard libraries: standard libraries.

点击(此处)折叠或打开

  1. 6 extensions to the c language family
  2. *************************************

  3. gnu c provides several language features not found in iso standard c.
  4. (the `-pedantic' option directs gcc to print a warning message if any
  5. of these features is used.) to test for the availability of these
  6. features in conditional compilation, check for a predefined macro
  7. `__gnuc__', which is always defined under gcc.

  8.  these extensions are available in c and objective-c. most of them are
  9. also available in c. *note extensions to the c language: c
  10. extensions, for extensions that apply _only_ to c.

  11.  some features that are in iso c99 but not c90 or c are also, as
  12. extensions, accepted by gcc in c90 mode and in c.


  13. 6.20 macros with a variable number of arguments.
  14. ================================================

  15. in the iso c standard of 1999, a macro can be declared to accept a
  16. variable number of arguments much as a function can. the syntax for
  17. defining the macro is similar to that of a function. here is an
  18. example:

  19.      #define debug(format, ...) fprintf (stderr, format, __va_args__)

  20. here `...' is a "variable argument". in the invocation of such a
  21. macro, it represents the zero or more tokens until the closing
  22. parenthesis that ends the invocation, including any commas. this set of
  23. tokens replaces the identifier `__va_args__' in the macro body wherever
  24. it appears. see the cpp manual for more information.

  25.  gcc has long supported variadic macros, and used a different syntax
  26. that allowed you to give a name to the variable arguments just like any
  27. other argument. here is an example:

  28.      #define debug(format, args...) fprintf (stderr, format, args)

  29. this is in all ways equivalent to the iso c example above, but arguably
  30. more readable and descriptive.

  31.  gnu cpp has two further variadic macro extensions, and permits them to
  32. be used with either of the above forms of macro definition.

  33.  in standard c, you are not allowed to leave the variable argument out
  34. entirely; but you are allowed to pass an empty argument. for example,
  35. this invocation is invalid in iso c, because there is no comma after
  36. the string:

  37.      debug ("a message")

  38.  gnu cpp permits you to completely omit the variable arguments in this
  39. way. in the above examples, the compiler would complain, though since
  40. the expansion of the macro still has the extra comma after the format
  41. string.

  42.  to help solve this problem, cpp behaves specially for variable
  43. arguments used with the token paste operator, `##'. if instead you
  44. write

  45.      #define debug(format, ...) fprintf (stderr, format, ## __va_args__)

  46. and if the variable arguments are omitted or empty, the `##' operator
  47. causes the preprocessor to remove the comma before it. if you do
  48. provide some variable arguments in your macro invocation, gnu cpp does
  49. not complain about the paste operation and instead places the variable
  50. arguments after the comma. just like any other pasted macro argument,
  51. these arguments are not macro expanded.


  52. 6.47 function names as strings
  53. ==============================

  54. gcc provides three magic variables that hold the name of the current
  55. function, as a string. the first of these is `__func__', which is part
  56. of the c99 standard:

  57.  the identifier `__func__' is implicitly declared by the translator as
  58. if, immediately following the opening brace of each function
  59. definition, the declaration

  60.      static const char __func__[] = "function-name";

  61. appeared, where function-name is the name of the lexically-enclosing
  62. function. this name is the unadorned name of the function.

  63.  `__function__' is another name for `__func__'. older versions of gcc
  64. recognize only this name. however, it is not standardized. for
  65. maximum portability, we recommend you use `__func__', but provide a
  66. fallback definition with the preprocessor:

  67.      #if __stdc_version__ < 199901l
  68.      # if __gnuc__ >= 2
  69.      # define __func__ __function__
  70.      # else
  71.      # define __func__ ""
  72.      # endif
  73.      #endif

  74.  in c, `__pretty_function__' is yet another name for `__func__'.
  75. however, in c, `__pretty_function__' contains the type signature of
  76. the function as well as its bare name. for example, this program:

  77.      extern "c" {
  78.      extern int printf (char *, ...);
  79.      }

  80.      class a {
  81.       public:
  82.        void sub (int i)
  83.          {
  84.            printf ("__function__ = %s\n", __function__);
  85.            printf ("__pretty_function__ = %s\n", __pretty_function__);
  86.          }
  87.      };

  88.      int
  89.      main (void)
  90.      {
  91.        a ax;
  92.        ax.sub (0);
  93.        return 0;
  94.      }

  95. gives this output:

  96.      __function__ = sub
  97.      __pretty_function__ = void a::sub(int)

  98.  these identifiers are not preprocessor macros. in gcc 3.3 and
  99. earlier, in c only, `__function__' and `__pretty_function__' were
  100. treated as string literals; they could be used to initialize `char'
  101. arrays, and they could be concatenated with other string literals. gcc
  102. 3.4 and later treat them as variables, like `__func__'. in c,
  103. `__function__' and `__pretty_function__' have always been variables.


  104. 6.55 other built-in functions provided by gcc
  105. =============================================

  106.  -- built-in function: int __builtin_function ()
  107.      this function is the equivalent to the preprocessor `__function__'
  108.      macro and returns the function name the invocation of the built-in
  109.      is in.
另,可参考:



阅读(1481) | 评论(0) | 转发(0) |
0

上一篇:

下一篇:

给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图