Chapter Contents

Previous

Next
Introduction to the SAS/C C++ Development System

Overview of the SAS/C C++ Development System

This release of the SAS/C C++ Development System implements the C++ language by means of a translator that translates C++ to C. The translated C code must be compiled with the SAS/C Compiler, resulting in an object module. The complete translation/compilation process for a C++ source program is shown in Translation Process .

Translation Process

[IMAGE]

By default, when you invoke the translator both the translation and compilation are performed; that is, you do not have to call the SAS/C Compiler as a separate step. Also by default, the C source is not saved, but is instead a temporary file and is discarded after compilation. You can control the translation and compilation of your program by specifying options when you invoke the translator. These options are described in Option Descriptions.

Once you have translated all the source modules in your program, use the COOL utility to link the object modules into a load module. Using this load module, you can call your program as you would call any other executable file under your operating system.


SAS/C C++ Development System Components

As shown in SAS/C C++ Development System Components , the SAS/C C++ Development System consists of three parts: a preprocessor, the translator, and a set of standard libraries.

SAS/C C++ Development System Components

[IMAGE]


Preprocessor

As part of the translation process, your C++ code is preprocessed. Expanded Translation Process builds on Translation Process , showing the two separate phases the translator goes through before producing C source.

Expanded Translation Process

[IMAGE]

Note that the preprocessing and translating phases of the translator are conceptual and may not be implemented as separate physical steps.

The preprocessor is the part of the C++ translator that transforms its input text (C++ source code, possibly containing preprocessing directives and operators) to C++ text devoid of preprocessing directives and in which a variety of lexical substitutions or operations may have been performed.

After the preprocessor step is completed, the translator translates your C++ code into C code. (If you want to stop after the preprocessing step and skip the translation or compilation steps, specify the pponly option, which is described in Option Descriptions .)

The preprocessor conforms to the ANSI Standard for C with the addition that it accepts C++ style comments and it correctly handles all C++ tokens. If you need more detailed information on a particular preprocessor feature, refer to the ANSI Standard for C or a C++ tutorial book.

Comments

The preprocessor supports both C++ style and C style comments. A C++ style comment begins with a double slash (//) and extends to the end of its line but not beyond. In contrast, a C style comment begins with a /* and ends with a * / and can take up multiple lines. For example, the following are some C++ style comments:

// This comment is too long to fit on one
// line, so it is continued on the second line.

int i; // declaration of an integer

Here are the equivalent C style comments:

/* This comment is too long to fit on one 
   line, so it is continued on the second line.*/

int i; /* declaration of an integer */

In general, the comment style you use depends entirely on personal preference. If you want to embed a comment within a line of code, you must use a C style comment, as in the following example:

x=y; /* One assignment */ a=b; // and another.

However, imbedding comments like this does not produce readable code and is not recommended.


Translator

After your C++ code has been preprocessed, it is translated into C code. You can control the translation with a variety of options, which are discussed in Option Descriptions .


Standard Libraries

This release of the SAS/C C++ Development System includes two standard libraries: the streams library and the complex library. Future releases of the product may include other libraries. The C++ I/O and the C++ Complex Library discuss the details of the functions and classes included in the streams and complex libraries.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.