Technical data
Cray Standard C/C++ Reference Manual
• Structures and unions that are declared identically in C and C++. In order
for structures and unions to be shared, they must be declared with identical
members in the identical order.
• Arrays and pointers to the above types.
In the following example, a Cray Standard C function (C_add_func) is called by
the Cray Standard C++ main function:
C++ Main Program
#include <iostream.h>
extern "C" int C_add_func(int, int);
int global_int = 123;
main()
{
int res, i;
cout << "Start C++ main" << endl;
// Call C function to add two integers and return result.
cout << "Call C C_add_func" << endl;
res = C_add_func(10, 20);
cout << "Result of C_add_func = " << res << endl;
cout << "End C++ main << endl;
}
The Cray Standard C function (C_add_func) is as follows:
#include <stdio.h>
extern int global_int;
int C_add_func(int p1, int p2)
{
printf("\tStart C function C_add_func.\n");
printf("\t\tp1 = %d\n", p1);
printf("\t\tp2 = %d\n", p2);
printf("\t\tglobal_int = %d\n", global_int);
return p1 + p2;
}
124 S–2179–36










