TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers


Print Reply
Laurent Guerby <[log in to unmask]>
Reply To:
Fri, 23 Jan 1998 15:27:00 +0100
text/plain (53 lines)
[Sorry for the highly technical post here]

> Can anyone point me to information on using Ada together with C++ on
> Windows NT?  The reason that I need to know is that someone here has
> spread the opinion that Ada and C++ runtimes are incompatible, so one
> cannot use Ada with C++ in the same program on NT.  I am sure that is
> not true, but I cannot find any evidence as I am not (yet) an NT
> developer.  This question has come up in early planning on a project in
> which  certain parts (mainly small prototype GUI sections) may be
> developed in C++, while other parts (algorithms, data manipulation) will
> be written in Ada 95.  Plans are for the final full-scale development to
> be completely in Ada 95.

   It is important to understand that it is not a language issue (*),
   but a specific compiler/system issue. On NT, and for C++ in
   general, there is no standard object format. Most of the time, you
   cannot mix objects produced from 2 different C++ compilers, and
   even if you could, it is unlikely to work because the 2 C++
   runtimes probably won't work together. The situation is the same
   between 2 Ada compilers (*).

   If you are in a multi-language project, it is in general better to
   avoid mixing languages in the same executable.

   It is far better (much less risk, less headaches) to separate the 2
   parts, and to use either a C-level interface, and/or some system
   interprocess communication (pipes, shared memory, messages,

   This generally has also a good impact on the application design,
   since it enforces subsystem boundaries. (Eg: avoiding to have GUI
   code spreaded all over the place in your code.)

   So to answer your question: at the language level (Ada 95 and C++)
   there's nothing that guarantee that it will work, experience
   indicates that it won't work.

   Unless of course you can find a particular Ada 95 compiler that was
   designed with cohabitating with a particular C++ runtime.

(*) Note that Ada 95, with Import, Export and Convention pragmas plus
    the adainit/adafinal implementation advice makes it easier to
    integrate other languages. I worked on a project where some of the
    code was compiled with the Sun C++ compiler and the rest with
    GNAT, we defined a C-level interface between the two parts, and
    linked with the C++ compiler linker calling adainit/adafinal from
    the C++ main and things worked fine (Motif, Ada tasking and C
    threading were there too, and it wasn't an academic example).

Laurent Guerby <[log in to unmask]>, Team Ada, Linux/GNU addict