tags:

views:

104

answers:

3

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 ?

+1  A: 

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.

Nikola Smiljanić
but will ANTLR generate proper C++ code ?
Eli
It will generate C code that is compilable with a C++ compiler
Patrick Daryll Glandien
+1  A: 

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

Simeon Pilgrim
+1  A: 

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.

MSalters