HP aC++/HP C A.06.20 Programmer's Guide
NOTE: As is the case with calling HP C from HP aC++, you must link your application
using HP aC++.
The main() Function
In general, when you mix C++ modules with modules in HP FORTRAN 90, the overall
control of the program must be written in C++. In other words, the main function must
appear in a C++ module, and no other outer block should be present.
Function Naming Conventions
When you call an HP FORTRAN 90 function from HP aC++, keep in mind the differences
in handling case sensitivity. HP FORTRAN 90 is not case sensitive, while HP aC++ is
case sensitive. Therefore, all C++ global names accessed by FORTRAN 90 routines must
be lowercase. All FORTRAN 90 external names are downshifted by default.
Using Reference Variables to Pass Arguments
There are two methods of passing arguments, by reference or by value. Passing by
reference means that the routine passes the address of the argument rather than the
value of the argument.
When calling HP FORTRAN 90 functions from HP aC++, ensure that the caller and
called functions use the same method of argument passing for each individual argument.
Furthermore, when calling external functions in HP FORTRAN 90, you must know the
calling convention for the order of arguments.
HP does not recommend passing structures or classes to HP FORTRAN 90. For
maximum compatibility and portability, pass simple data types to routines. All HP
aC++ parameters are passed by value, as in HP C, except arrays and functions which
are passed as pointers.
HP FORTRAN 90 passes all arguments by reference. This means that all actual
parameters in an HP aC++ call to a FORTRAN routine must be pointers, or variables
prefixed with the unary address operator, &.
The simplest way to reconcile these differences in argument-passing conventions is to
use reference variables in your C++ code. Declaring a parameter as a reference variable
in a prototype causes the compiler to pass the argument by reference when the function
is invoked.
Example of Reference Variables as Arguments
The following example illustrates a reference variable:
int main( void )
{
// declare a reference variable
extern void pas_func( short & );
short x;
252 Mixing C++ with Other Languages