Closed. This question needs to be more focused. It is not currently accepting answers. Learn more
想改进这个问题吗?更新问题,使其只关注一个问题editing this post
三年前关闭。
什么是C语言中的声明符说明符和类型说明符?
用户可以定义或创建声明符说明符或类型说明符吗?
我正在阅读GCC源代码,如果你能给我一些建议,我会非常感谢!
下面是来自GCC/c-tree.h
/* A kind of type specifier.  Note that this information is currently
   only used to distinguish tag definitions, tag references and typeof
   uses.  */
enum c_typespec_kind {
  /* No typespec.  This appears only in struct c_declspec.  */
  ctsk_none,
  /* A reserved keyword type specifier.  */
  ctsk_resword,
  /* A reference to a tag, previously declared, such as "struct foo".
     This includes where the previous declaration was as a different
     kind of tag, in which case this is only valid if shadowing that
     tag in an inner scope.  */
  ctsk_tagref,
  /* A reference to a tag, not previously declared in a visible
     scope.  */
  ctsk_tagfirstref,
  /* A definition of a tag such as "struct foo { int a; }".  */
  ctsk_tagdef,
  /* A typedef name.  */
  ctsk_typedef,
  /* An ObjC-specific kind of type specifier.  */
  ctsk_objc,
  /* A typeof specifier, or _Atomic ( type-name ).  */
  ctsk_typeof
};

最佳答案

C语言声明
在C语言中,声明的语法形式为:

declaration-specifiers declarator

声明符是变量、函数或指针,基本上与声明对象的名称相对应。
说明符可以是type specifierslikeint, unsigned, etc.storage class specifierliketypedef, extern, statictype qualifierslikeconst, volatile, etc.
例如在下面的声明中:
typedef long double DBL;

我们引入了一个新的类型名DBL,它是long double的别名,我们有:
typedef:存储类说明符
长双精度:类型说明符
DBL:声明符
当使用typedef时,基本上是用一个新名称给类型说明符起别名如果在下面键入def这样的结构:
typedef struct {
   int a;
   int b;
} mystruct;

然后可以将变量的类型指定为mystruct,如下所示:
mystruct c;

相关职位:
What are declarations and declarators and how are their types interpreted by the standard?
How do I use typedef and typedef enum in C?
Declaration specifiers and declarators

关于c - 什么是C语言中的声明符说明符? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35218641/

10-11 21:03