HPlogo HP C++ Programmer's Guide: HP 9000 Series Workstations and Servers > Chapter 5 Inter-Language Communication

Introduction

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

A module is a file containing one or more variable or function declarations, one or more function definitions, or similar items logically grouped together. Mixing modules written in C++ with modules written in C is relatively straightforward since C++ is essentially a superset of C. Mixing C++ modules with modules in languages other than C is more complicated.

When creating an executable file from a group of programs of mixed languages, one of them being C++, you need to be aware of the following:

  • In general, the overall control of the program must be written in C++. In other words, the main() function should appear in a C++ module.

  • You must pay attention to case-sensitivity conventions for function names in the different languages.

  • You must make sure that the data types in the different languages correspond. Do not mismatch data types for parameters and return values.

  • Storage layouts for aggregates differ between languages.

  • You must use the extern "C" linkage specification to declare any modules that are not written in C++; this is true whether or not the module is written in C.

  • You must use the extern "C" linkage specification to declare any modules that are written in C++ and called from other languages.

NOTE: HP C++ classes are not accessible to non-C++ routines.
© Hewlett-Packard Development Company, L.P.