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).

  1. HC can freely call C++ libraries. 
  2. HC code cannot arbitrarily be called from C++
  3. 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:

  1. 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).
  2. Design and implement the parallel HC code with calls to the existing C++ libraries
  3. 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:

  1. Compile the C++ code into object files or libraries using a C++ compiler
  2. Compile the HC code into object files or libraries using the HCC compiler
  3. 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
  • No labels