为什么是“数组”? 在 Visual-C++ 中标记为保留字?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
事实并非如此。 至少在标准 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.
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.
在什么版本? 谷歌搜索“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
事实上,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.它不是保留字,但 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.
它不是 ISO 标准下的保留字。 Microsoft 的 C++/CLI 定义 数组 在 cli 命名空间,Visual Studio 的语法突出显示会将其视为保留字。 此用法将被视为供应商扩展,而不是任何国际 C 或 C++ 标准的一部分。
ISO C99 关键字:
ISO C++98关键词:
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:
ISO C++98 Keywords:
它用于 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."