This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A FrontEnd in C++?


On 17-Aug-2002, khalid aggag <khalidaggag@hotmail.com> wrote:
> I am currently developing a new Frontend for an educational language for 
> GCC. I have the language's lexical analysis and parsing modules in C++. Is 
> it possible to develop a frontend for gcc written completely in C++?

Yes, it is possible.
People have written frontends for gcc in languages other than C before.
For example, the Ada front-end is written in Ada, and the Mercury
front-end is written in Mercury.  These both include a small amount
of C code to interface with the GCC back-end, but if you're writing
in C++ you should be able to avoid that.  You might need to make
some minor modifications to the GCC header files, though.

> How 
> would I make up for the different function naming and calling conventions 
> between C and C++? Thanx alot in advance.

Use `extern "C"', either in the C++ code, e.g.

	extern "C" {
	  #include "tree.h"
	}

or by modifying the GCC headers, e.g.

	/* tree.h */
	#ifdef __cplusplus
	extern "C" {
	#endif

	... body of tree.h goes here

	#ifdef __cplusplus
	}
	#endif

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]