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

发布于 2024-07-10 15:01:56 字数 105 浏览 4 评论 0原文

Visual Studio 语法突出显示将此单词设置为蓝色,就好像它是关键字或保留字一样。 我尝试在线搜索它,但“数组”一词使搜索失败,我得到的大部分页面都解释了数组是什么。 它是干什么用的?

Visual Studio syntax highlighting colors this word blue as if it were a keyword or reserved word. I tried searching online for it but the word "array" throws the search off, I get mostly pages explaining what an array is. What is it used for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

奶气 2024-07-17 15:01:57

事实并非如此。 至少在标准 C/C++ 中不是这样。

现在你可能询问为什么“entry”是 K& 中 C 语言中的保留字;R 但不是在 C99 中 - 有人认为他们可能会在某个时候添加该功能,但最终决定反对。

It isn't. At least not in standard C/C++.

Now you might well ask the reason "entry" was a reserved word in C in K&R but not in C99 - somebody thought they might add the feature at some point, but eventually decided against it.

雨后彩虹 2024-07-17 15:01:57

Visual Studio 从不费心为其漂亮的打印机定义不同的 C++ 语法。 ISO C++、VC++、C++/CLI 或只是旧的 C - 都共享相同的语法。 因此,像数组和接口这样的名称都被视为关键字。

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

Visual Studio never bothered with defining different C++ grammars for their pretty printer. ISO C++, VC++, C++/CLI, or just old C - all share the same grammar. So, names like array and interface are all treated as if they were keywords.

It would also be quite hard for the pretty printer to spot the C++ dialect used in foo.cpp. You'd need to compile the code for that. Currently the pretty printer can operate on tokens, which means it only needs to parse the code.

往事随风而去 2024-07-17 15:01:57

在什么版本? 谷歌搜索“c++保留字”显示没有这样的用法。

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

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

In what edition? A Google search for "c++ reserved words" shows no such usage.

I routinely use "array" in sample code.

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

逆光下的微笑 2024-07-17 15:01:57

事实上,MSVC 中突出显示的单词并不意味着它是 C 或 C++ 关键字。 正如您所看到的,它还突出显示了许多非标准的内容,例如 __int64甚至 __int128< /code> 虽然 MSVC 中没有 128 位 int 类型

The fact that a word's being highlighted in MSVC doesn't mean that it's a C or C++ keyword. As you can see, it also highlights many non-standard things like __int64, or even __int128 although there's no 128-bit int type in MSVC.

甜柠檬 2024-07-17 15:01:57

它不是保留字,但 Microsoft Visual Studio 决定将其标记为蓝色,就好像它是保留字一样,但它绝对不是根据 DD Malik 的“C++ 编程第五版”。

It is not a reserved word, but Microsoft Visual Studio decided to mark it blue as if it were a reserved word, but it most definitely is not according to "C++ Programming 5th Edition" by D.D. Malik.

み零 2024-07-17 15:01:56

它不是 ISO 标准下的保留字。 Microsoft 的 C++/CLI 定义 数组cli 命名空间,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

It's not a reserved word under ISO standards. Microsoft's C++/CLI defines array in the cli namespace, and Visual Studio's syntax highlighting will treat it as a reserved word. This usage would be considered a vendor extension and not a part of any international C or C++ standard.

ISO C99 Keywords:

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 Keywords:

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
绝對不後悔。 2024-07-17 15:01:56

它用于 C++/CLI。

Visual C++ 语言参考: “数组关键字让您创建一个在公共语言运行时堆上分配的动态数组。”

It's used in C++/CLI.

Visual C++ Language Reference: "The array keyword lets you create a dynamic array that is allocated on the common language runtime heap."

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文