HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)

NOTE: HP aC++ classes are not accessible to non-C++ routines.
Data Compatibility between C and C++
Many of the data types between C and C++ are identical as C++ is, for most part, a
superset of C. Both languages support char, short, int, long, float, and double
data types. ANSI C and HP C++ also support a long double type. In addition, HP
aC++ supports bool, wchar_t, long long, and unsigned long long data types.
Pointers, structs, and unions that can be declared in C are also compatible. Arrays
composed of any of the above types are compatible.
C++ classes are generally incompatible with C structs. The following features of the C++
class facility may cause the compiler to generate extra code, extra fields, or data tables:
Multiple visibility of members (including both private and public data members in
a class)
Inheritance, either single or multiple
Virtual functions
It is the use of these features, as opposed to whether the class keyword is used rather
than struct, that introduces incompatibilities with C structs.
HP aC++ Calling HP C
Calling between C and C++ is a normal operation, since C++ is for the most part a
superset of C. You should, however, be aware of the following:
Using the extern "C" Linkage Specification
Differences in Argument Passing Conventions
The main() Function
Using the extern "C" Linkage Specification
To handle overloaded function names the HP aC++ compiler generates new, unique
names for all functions declared in a C++ program. To geneate these names, the compiler
uses a function-name encoding scheme that is implementation dependent. A linkage
directive tells the compiler to inhibit this default encoding of a function name for a
particular function.
To call a C function from a C++ program, you must disable the usual encoding scheme
when you declare the C function. When you do not disable the usual encoding scheme,
the function name declared in your C++ program will not match the function name in
your C module defining the function.
When the names do not match, the linker cannot resolve them. To avoid these linkage
problems, use a linkage directive when you declare the C function in the C++ program.
236 Mixing C++ with Other Languages