我在哪里可以找到涵盖K&R1/2,C89-C1X及其起源的C(和/或C++)关键字列表?

Joh*_*zem 4 c c++ language-lawyer

我已经接触过许多编码指南,每个编程指南都为命名"事物"提供了指导.一个特定的C89命名规则触发了这个问题:明确禁止对变量使用名称"new",因为在C++中这是一个关键字.

这让我想到了下一个标准,C99有很好的文献记载,但C11相对较新(2014).标准委员会还有几个扩展仍在进行中.

因此,我想知道是否有人可以提供包含关键字及其来源的列表,以便制定一组命名规则,包括为什么要避免使用多个名称的原因.

虽然严格说话complex不是关键词,但最好包括类似的定义.而且C++信息也很受欢迎.

Mar*_*ork 6

来自n3242(即C++ 11)

2.12关键词

表4 - 关键字

alignas  alignof          asm           auto         bool
break    case             catch         char         char16_t
char32_t class            const         constexpr    const_cast 
continue decltype         default       delete       double 
do       dynamic_cast     else          enum         explicit 
export   extern           false         float        for 
friend   goto             if            inline       int 
long     mutable          namespace     new          noexcept 
nullptr  operator         private       protected    public 
register reinterpret_cast return        short        signed 
sizeof   static           static_assert static_cast  struct 
switch   template         this          thread_local throw 
true     try              typedef       typeid       typename 
union    unsigned         using         virtual      void
volatile wchar_t          while
Run Code Online (Sandbox Code Playgroud)

表5 - 替代表示

and      and_eq           bitand        bitor       compl
not      not_eq           or            or_eq       xor
xor_eq
Run Code Online (Sandbox Code Playgroud)

从n1256(C99)

A.1.2关键词

auto     enum             break         extern      case
float    char             for           const       goto
continue if               default       inline      do
int      double           long          else        register
restrict return           short         signed      sizeof
static   struct           switch        typedef     union
unsigned void             volatile      while       _Bool
_Complex _Imaginary
Run Code Online (Sandbox Code Playgroud)

  • @Als"长久"是两个字.实际上有两个关键字. (2认同)