[antlr-interest] Making c target work with c++

Stuart Dootson stuart.dootson at gmail.com
Tue Jun 12 09:57:41 PDT 2007

On 12/06/07, Loring Craymer <lgcraymer at yahoo.com> wrote:
> This is a language issue; C++ mangles names unless
> they are declared as being "C" items.
> Change your prototype to
> extern "C" CParser_Ctx_struct *CParserNew(struct
> and make similar changes as required.
> --Loring

Alternatively, in your main.cpp, use this:

extern "C" {
#include <antlr-headers>
#include "your-parser-and-lexer-headers"

That way you won't need to edit generated code or Jim's C runtime for Antlr.

Jim - any chance of the C runtime and code generator adding extern "C"
to function declarations conditional on presence of the '__cplusplus'

Stuart Dootson

More information about the antlr-interest mailing list