Eli
Eli

Reputation: 6663

antlr : C++ target with visual studio 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 ?

Upvotes: 0

Views: 518

Answers (4)

Gokul
Gokul

Reputation: 933

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

Upvotes: 1

MSalters
MSalters

Reputation: 179779

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 use int and foo, 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.

Upvotes: 1

Simeon Pilgrim
Simeon Pilgrim

Reputation: 25903

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++.

Upvotes: 1

Nikola Smiljanić
Nikola Smiljanić

Reputation: 26873

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.

Upvotes: 1

Related Questions