On 07/12/2011 08:54 AM, Arnaud Charlet wrote: >> I'm not sure because I don't think we want to compile the C files of the Ada >> > runtime with the C++ compiler. We want to do that only for the compiler. > > Right, we definitely don't want to use the C++ compiler for building the > Ada run-time.
But apparently they already are (when building the compiler), otherwise the patch in http://gcc.gnu.org/ml/gcc/2009-06/txt00004.txt would make no sense: Index: gcc/ada/env.c =================================================================== --- gcc/ada/env.c (revision 148953) +++ gcc/ada/env.c (working copy) @@ -29,6 +29,11 @@ * * ****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + #ifdef IN_RTS #include "tconfig.h" #include "tsystem.h" @@ -313,3 +318,7 @@ clearenv (); #endif } + +#ifdef __cplusplus +} +#endif Perhaps it is better to always build those files with cc, perhaps not. Since there are two versions of the Ada RTL, the one in the compiler and the one in libada, my questions are: 1) Do they share any object files when not cross-compiling? 2) If not, is using C++ for the former okay? If the answers are "no" and "yes" respectively, I still think a patch like the one I suggested, where the host files in gcc/ are uniformly compiled with C++, is preferrable. You do need to force usage of a C compiler when compiling libada: Index: Makefile.in =================================================================== --- Makefile.in (revision 169877) +++ Makefile.in (working copy) @@ -2451,6 +2451,7 @@ gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../ $(MAKE) -C $(RTSDIR) \ CC="`echo \"$(GCC_FOR_TARGET)\" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \ + ENABLE_BUILD_WITH_CXX=no \ INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \ CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \ FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \ @@ -2459,6 +2460,7 @@ gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../ $(MAKE) -C $(RTSDIR) \ CC="`echo \"$(GCC_FOR_TARGET)\" \ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \ + ENABLE_BUILD_WITH_CXX=no \ ADA_INCLUDES="" \ CFLAGS="$(GNATLIBCFLAGS)" \ ADAFLAGS="$(GNATLIBFLAGS)" \ And of course extern "C" needs to be added to the headers, so that public symbols used by compiled Ada source are not mangled. However, static and private symbols need not be extern "C". Paolo