Using C++ within a backend?

Kevin Handy kth@srv.net
Tue Apr 15 21:36:00 GMT 2003


Matthieu Moy wrote:

>Alexandre Courbot <Alexandre.Courbot@lifl.fr> writes:
>
>  
>
>>Hi all,
>>    
>>
>
>Hi,
>
>  
>
>>Since  I need  to  use  the type-checking  system  designed for  the
>>architecture I'm porting  gcc to, I'll need to use  C++ code from my
>>backend (the library I have to link to is written in C++). I thought
>>this  might be  a  good idea  to write  as  much of  the backend  as
>>possible in C++, and define the needed functions as extern "C". 
>>    
>>
>
>I have  the same problem with  the file tree.h, which  I can't include
>from a C++ program, even with 
>
>extern "C" {
>#include "..."
>}
>
>For now, I'm writting  most of my code in pure C,  and I have wrappers
>around C++ functions  written in C. When  I want to use a  tree from a
>C++ file, I just typedef it to be a void *. 
>
>But in the long run, I think that GCC's header files should compile in
>C++  :  That would  be  simpler  for code  reuse  and  linking to  C++
>libraries,  and anyway, most  of the  time, when  a C  program doesn't
>compile in C++, this is because it's too dirty ... 
>

Might it be useful to make the entire gcc compiler compilable by
the C++ compiler in some future version?  i.e. make the C files
capable of being compiled using the C++ compiler, not converting
them to C++. This would require changing the K&R definitions
to inline ones, but since that appears to be in the plan anyway...

I'd think that being able to use different front ends to compile GCC
might help uncover latent bugs and ambigous constructs (since the C
and C++ front ends use different parsers, iirc).




More information about the Gcc mailing list