/*---------------------------------------------------------------------+
| Copyright (c) 1995, SAS Institute Inc. |
| Unpublished - All Rights Reserved |
| S A S / C S A M P L E |
| |
| |
| NAME: CXXTOC1 |
| LANGUAGE: C++ |
| PURPOSE: Call a C function from a C++ main(). Then, call a C++ |
| function from a C function. |
| MVS - |
| COMPILE: Use AUX(CXXTOC). Compiled using LC370C for C, LCXX |
| for C++. |
| LINK: Use AUX(CXXTOC). Linked using LCXXL. |
| EXECUTE: Use AUX(CXXTOC). Call <prefix>.LOAD(CXXTOC). |
| NOTES: |
| TSO - |
| COMPILE: Compile using LC370C for C, LCXX for C++. |
| LINK: Link the C and C++ object modules using CLK370 with |
| "CXX" option. |
| EXECUTE: Call <prefix>.LOAD(CXXTOC). |
| NOTES: |
| CMS - |
| COMPILE: Compile using LC370C for C, LCXX for C++. |
| LINK: Link the C and C++ object modules using CLINK with |
| "CXX" and "GENMOD" options. |
| EXECUTE: Call CXXTOC. |
| NOTES: |
| MISC NOTES: This example consists of 2 modules. CXXTOC1 is the C |
| source module. CXXTOC2 is the C++ source module. |
| |
+---------------------------------------------------------------------*/
#include <iostream.h>
extern "C" gotoc(); /* the C function called from C++ */
void main() /* a C main() */
{
cout <<"Starting in C++ main()" << endl;
cout <<"Call a C function" << endl;
gotoc();
cout <<"Leaving the C++ main()" << endl;
}
void extern "C" callcxx() /* a C++ function */
{
cout <<"This is C++ function callcxx()" << endl;
cout <<"Returning to C" << endl;
}