Habanero-C language and tool chain are C-based, so if you would like to mix the HC code with legacy C++ code, there are some restrictions (that are similar to the C-C++ interoperability restrictions).
- 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 parallel HC code should be as follows:
- Decompose the existing C++ code into library functions that can be called individually from HC. The existing C++ code should be thread-safe (it should not include globally shared data that could lead to data races 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. Since HC compiler is C-based and cannot link against the C++ libraries (C++ compiler 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 be as follows:
- Compile the C++ code into object files or libraries using a C++ compiler
- Compile the HC code into object files or libraries using the HCC compiler
- Compile the main C++ file using a C++ compiler, and link everything from 1., 2. and 3. into an executable using the same C++ compiler