This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Using C++ within a backend?
- From: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Tue, 15 Apr 2003 12:19:02 +0200
- Subject: Using C++ within a backend?
Hi all,
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". This might not be a good idea for bootstrapping but is fine in my
case anyway, since I only want a basic cross-compiler.
Problem is, g++ (3.2.3 here) doesn't seem to like gcc's include files.
Whenever I include rtl.h for instance, I get:
../../gcc-3.2.2-camille/gcc/rtl.h:109: declaration of
`rtx_def*rtunion_def::rtx
'
config.h:8: changes meaning of `rtx' from `typedef struct rtx_def*rtx'
../../gcc-3.2.2-camille/gcc/rtl.h:110: declaration of `
rtvec_def*rtunion_def::rtvec'
config.h:10: changes meaning of `rtvec' from `typedef struct rtvec_def*rtvec'
Effectively, line 109 of rtl.h is
rtx rtx;
Which I understand cause problems to g++.
I've thought of working this around by writing C code when necessary and C++
when possible, but it would involves making messy wrappers. Another solution
would be to say g++ to treat a part of the program as pure C, this I haven't
found neither. Putting the includes within an extern "C" clause doesn't help,
and the doc doesn't mention a command-line option that would make g++ more
permissive with the code.
I'm also surprised I haven't found anything about this topic in the archives -
I'd have bet this was a common question. Has somebody here messed up with C++
in the backend and could advice me? Is it possible to safely include gcc's
include files from a C++ file?
Thanks for any advice!
Alex.