Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find a list of C (and/or C++) keywords covering K&R1/2, C89-C1X and their origins? [closed]

I've been exposed to numerous coding guidelines, every one of them giving guidelines for naming 'things'. One specific C89 naming rule triggered this question: It was explicitly forbidden to use the name 'new' for a variable, because in C++ this is a keyword.

This started me thinking about the next standards, C99 is well documented, but C11 is relatively new (2014). And the Standards committee has several extensions still in the works.

Therefore I'm wondering if someone can provide a list with keywords and their origins, in order to make a set of naming rules, including the reasons why several names are to be avoided.

And although strictly spoken complex is not a keyword, similar definitions would best be included. And C++ information is also appreciated.

like image 553
Johan Bezem Avatar asked Feb 23 '23 09:02

Johan Bezem


1 Answers

From n3242 (ie C++11)

2.12 Keywords

Table 4 — Keywords

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

Table 5 — Alternative representations

and      and_eq           bitand        bitor       compl
not      not_eq           or            or_eq       xor
xor_eq

From n1256 (C99)

A.1.2 Keywords

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
like image 105
Martin York Avatar answered Feb 24 '23 23:02

Martin York