Date: Fri, 29 Mar 2024 09:14:30 -0500 (CDT)
Message-ID: <643160445.1185.1711721670535@wiki-n2.rice.edu>
Subject: Exported From Confluence
MIME-Version: 1.0
Content-Type: multipart/related;
boundary="----=_Part_1184_400877353.1711721670534"
------=_Part_1184_400877353.1711721670534
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Content-Location: file:///C:/exported.html
Interoperability with C++
Interoperability with C++
Habanero-C language and tool chain are C-based, so if you w=
ould like to mix the HC code with legacy C++ code, there are some restricti=
ons (that are similar to the C-C++ interoperability restric=
tions).
- HC can freely call C++ libraries.
- HC code cannot arbitrarily be called from C++
- The only HC function that should be called from C++ is the hc_main
The process of creating an application using legacy C++ code and paralle=
l HC code should be as follows:
- Decompose the existing C++ code into library functions that can be call=
ed individually from HC. The existing C++ code should be thread-s=
afe (it should not include globally shared data that could lead to data rac=
es if it is called in parallel).
- Design and implement the parallel HC code with calls to the existing C+=
+ libraries
- Write a main C++ function that calls the main HC function hc_main. Sinc=
e HC compiler is C-based and cannot link against the C++ libraries (C++ com=
piler mangles the function names to support object-oriented features), you =
will have to use a C++ compiler to do the final linking (see below)
The build process for code that consists of both HC an C++ code should b=
e as follows:
- Compile the C++ code into object files or libraries using a C++ compile=
r
- Compile the HC code into object files or libraries using the HCC compil=
er
- Compile the main C++ file using a C++ compiler, and link everything fro=
m 1., 2. and 3. into an executable using the same C++ compiler
------=_Part_1184_400877353.1711721670534--