aCC -oexecutable cfilename.o C++filename.o

NOTE: During the linking phase, the aCC driver program performs several functions to support the C++ class mechanism. Linking programs that use classes with the C compiler driver cc leads to unpredictable results at run time.

Calling HP FORTRAN 90 from HP aC++

This section discusses the following topics:

The main() Function

Function Naming Conventions

Using Reference Variables to Pass Arguments

Using extern "C" Linkage

Strings

Arrays

Files in FORTRAN

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:

Data Compatibility between C and C++ 193

Page 193
Image 193
HP C/aC++ for PA-RISC Software manual Calling HP Fortran 90 from HP aC++, Function Naming Conventions