antlr : C++ Visual Studio 2008 的目标
Antlr 网站对于编译 C++ 语法的主题并不清楚, 它说该工具将生成与 C++ 兼容的 C 代码,这是什么意思?我可以用 VS 2008 编译这段代码吗?
the Antlr site is not clear on the subject of compiling a grammar for C++,
it says that the tool will generate C code compatible with C++, what dose it mean? will I be able to compile this code with VS 2008 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
VS 2008同时具有C和C++编译器(并且C++编译器可以编译C代码,这就是他们的意思),我认为你不会有任何问题。
他们说:“从版本 3.1 开始,C 目标与 C++ 兼容,将 .c 文件编译为 C++。C+ 类将在 2008 年晚些时候作为单独的库提供。”
这意味着它与 C++ 兼容。
VS 2008 has both C and C++ compiler (and C++ compiler can compile C code, this is what they meant), I don't think you'll have any problems.
They say: "C target as of release 3.1 is C++ compatible, compile .c files as C++. C+ classes will be provided as a separate library later in 2008."
Meaning it's C++ compatible.
C 主要是 C++ 的子集。但生成的 C 代码不应该偏离 C++ 的老路,因此应该是有效的 C++。
Visual Studio有一个C/C++编译器,当你编译生成的解析器时,你不需要担心C/C++的区别。只需将代码编译为 C++ 即可。
C is mostly a subset of C++. But the generated C code should not go off the C++ beaten path, so will should be valid C++.
Visual Studio has a C/C++ compiler, as you are compiling the generated parser, you do not need to worry about the C/C++ distinction. Just compile the code as C++.
短语“与 C++ 兼容的 C 代码”意味着代码生成的目标是 C 和 C++ 的公共子集。因此,它不使用在 C 和 C++ 等中具有不同含义的标记
class
。但它可以使用int
和foo
,C 和 C++ 都同意。因此,生成的代码可以由 C 和 C++ 编译器编译。 Visual Studio 包含这两种模式(通过
/TC
和/TP
标志),因此您可以使用任一模式。The phrase "C code compatible with C++" means that the code generation targets the common subset of C and C++. Hence, it does not use the token
class
which has different meanings in C and C++, etctera. But it can useint
andfoo
, where C and C++ agree.As a result, the code generated can be compiled by both C and C++ compilers. Visual Studio contains both (via
/TC
and/TP
flags) so you could use either mode.我已经上传了 ANTLR 的 C++ 目标。查看运行时库 - C++ 目标下的 ANTLR wiki
http://www. antlr.org/wiki/pages/viewpage.action?pageId=29130826
I have uploaded a C++ Target for ANTLR. check out the ANTLR wiki under Runtime Libraries - C++ Target
http://www.antlr.org/wiki/pages/viewpage.action?pageId=29130826