为什么“数组”在Visual-C ++中被标记为保留字?

时间:2008-12-16 20:31:14

标签: arrays visual-studio visual-c++ c++-cli

Visual Studio语法突出显示该单词为蓝色,就像它是关键字或保留字一样。我尝试在网上搜索它,但是“数组”这个词引发了搜索,我得到的主要是解释数组是什么的页面。它用于什么?

7 个答案:

答案 0 :(得分:65)

根据ISO标准,它不是保留字。 Microsoft C++/CLIarray中定义cli namespace,Visual Studio的语法突出显示将其视为保留字。此用法将被视为供应商扩展,而不是任何国际C或C ++标准的一部分。

ISO C99关键字:

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

ISO C ++ 98关键词:

and         double          not                 this 
and_eq      dynamic_cast    not_eq              throw 
asm         else            operator            true 
auto        enum            or                  try 
bitand      explicit        or_eq               typedef 
bitor       export          private             typeid 
bool        extern          protected           typename 
break       false           public              union 
case        float           register            unsigned 
catch       for             reinterpret_cast    using 
char        friend          return              virtual 
class       goto            short               void 
compl       if              signed              volatile 
const       inline          sizeof              wchar_t 
const_cast  int             static              while 
continue    long            static_cast         xor 
default     mutable         struct              xor_eq
delete      namespace       switch     
do          new             template

答案 1 :(得分:11)

不是。至少不是标准的C / C ++。

现在你很可能ask the reason "entry" was a reserved word in C in K&R但不是在C99中 - 有人认为他们可能会在某个时候添加这个功能,但最终决定反对它。

答案 2 :(得分:10)

它在C ++ / CLI中使用。

Visual C++ Language Reference:“array关键字允许您创建在公共语言运行时堆上分配的动态数组。”

答案 3 :(得分:2)

Visual Studio从不为他们漂亮的打印机定义不同的C ++语法而烦恼。 ISO C ++,VC ++,C ++ / CLI或者只是旧的C - 都共享相同的语法。因此,数组和接口等名称都被视为关键字。

漂亮的打印机也很难发现foo.cpp中使用的C ++方言。您需要为此编译代码。目前,漂亮的打印机可以对令牌进行操作,这意味着它只需要解析代码。

答案 4 :(得分:1)

在哪个版本?谷歌搜索“c ++保留字”没有显示这种用法。

我经常在示例代码中使用“array”。

http://cs.smu.ca/~porter/csc/ref/cpp_keywords.html

答案 5 :(得分:0)

这不是一个保留字,但微软视觉工作室决定将其标记为蓝调,好像它是一个保留字,但它绝对不是根据D.D.的“C ++编程第5版”。马立克。

答案 6 :(得分:0)

在MSVC中突出显示一个单词这一事实并不意味着它是一个C / C ++关键字。正如您所看到的,它还突出显示了许多非标准内容,例如__int64,甚至__int128,尽管VC中没有128位int类型。