Chapter Contents |
Previous |
Next |
Introduction to the SAS/C C++ Development System |
and
, and_eq
,
and so on).
atexit()
.
extern inline
.
Inline functions with external linkage, such as member functions, may have
different addresses in different compilation units. Also static variables
defined inside such functions will refer to different objects in different
compilation units.
asm
declaration.
export
keyword or separate compilation of template definitions.
C++ code written for previous releases of the SAS/C C++ Development System generally will be accepted by Release 7.00. However, in this release the C++ Standard has taken priority over compatibility with older code in determining the language accepted. Some changes which may cause compatiblity problems are noted in Improved Conformance with the C++ Standard.
For a complete list of which anachronisms are supported by the SAS/C C++ Development System, see Anachronisms .
Improved Conformance with the C++ Standard |
chars
are now correctly typed as int
.
All but the last character are now ignored in wide character literals with
multiple chars
.
Note:
The C++ translator still injects the names from friend
declarations into the containing namespace when defining
a class, so such declarations will always be considered if lookup includes
the containing namespace.
operator new[]
and operator delete[]
forms of the allocation and deallocation
functions are now supported. Note that any user-defined new operators now
need the corresponding array versions to be declared if they are to be used
for array allocation.
operator new[]( size_t, void* ),could easily be called and produce unexpected results.
operator new
and
new[]
by throwing
a
std::bad_alloc
exception. The nothrow
placement new operators are now defined. These operators do not exit via
throw and report failure by returning NULL.
bool
and wchar_t
type keywords.
const char*
in certain cases, which will cause errors with some C and older C++ code.
void
functions.
mutable
storage class
specifier for class members is now supported.
explicit
function specifier
is supported.
int
underlying types. The
translator will use unsigned int
as the underlying type if one of the enumeration
constant values is an unsigned quantity outside the range of int
.
const
objects that are not explicitly initialized and do not
have a user-defined default constructor.
{}
,
may now be used as an aggregate initializer.
const
references to non-lvalues is no longer
allowed. Warning LSCT550 was formerly generated in such situations.
const
data members with
integral or enumeration types may be initialized with a constant expression
when declared in the class body.
enums
.
operator[]
and operator+
should
be noted. The signatures formerly included combinations of a pointer and any
integral index type. The index type has changed to ptrdiff_t
(a signed type). This may cause ambiguity errors with existing
code.
EXCEPT
option.
#if
expressions have
been corrected to match the C++ rules.
<stdio.h>
includes <cstdio>
) and
provide using declarations to make the appropriate names available in both
the global and std
namespace scopes.
Incompatibility with Previous Releases |
Environmental Elements |
This section describes four important environmental elements:
The special characters that can be customized are braces, square brackets, circumflex, tilde, backslash, vertical bar, pound sign, and exclamation point. You should determine if your site has customized values for these characters and find out what the values are. Otherwise, the default representations listed in Default Representations for Special Characters are in effect. Consult your SAS Installation Representative for details about customized values. Default Representations for Special Characters shows the two possible default representations for each character. These primary and alternate representations in columns two and three are EBCDIC equivalents of the characters in hexadecimal notation.
extern | 16,777,215 (16M-1) bytes |
static | 8,388,607 (8M-1) bytes |
auto | 8,388,607 (8M-1) bytes |
formal | 65,535 (64K-1) bytes. |
Individual objects can be up to 8 megabytes in size. The translator imposes no limit on array sizes.
The following types of programs generate very large CSECTS:
norent
and with large amounts of
static
or defined
external data or both
rentext
and
with large amounts of
static
data.
You should consider alternatives to using large amounts
of
static
data. One alternative is to use the
new
operator
for dynamic storage allocation. Storage allocated with the new operator is
limited only by available memory.
The numerical limits are what one would expect for a 32-bit, twos complement machine such as the IBM 370. Integral Type Sizes shows the size ranges for the integral types.
Float and Double Type Sizes shows the size ranges for float and double types.
Type | Length in Bytes | Range |
---|---|---|
float
|
4 | +/- 5.4E-79 to +/- 7.2E75 |
double
|
8 | +/- 5.4E-79 to +/- 7.2E75 |
long double
|
8 | +/- 5.4E-79 to +/- 7.2E75 |
Language Elements |
This section describes how the translator treats character constants and string literals.
char
value for certain alphabetic escape sequences that represent nongraphic
characters. This
char
value corresponds to the hex values shown in
column 2 of Escape Sequence Values .
Sequence | Hex Value | Meaning |
---|---|---|
\a | 0x2f | alert |
\b | 0x16 | backspace |
\f | 0x0c | form feed |
\n | 0x15 | newline |
\r | 0x0d | carriage return |
\t | 0x05 | horizontal tab |
\v | 0x0b | vertical tab |
NOSTringdup
compiler option can be used to force
a separate copy to be generated for each use of a string literal. However,
modifying string constants is not recommended and renders a program nonreentrant.
Note:
Strings used to initialize
char
arrays (not
char*
) are not
actually generated because they are shorthand for a comma-separated list of
single-character constants.
The translator supports several predefined constants:
_ _cplusplus
c_plusplus
_ _DATE_ _
_ _DATE_ _
in your
source code.
_ _FILE_ _
_ _FILE_ _
in your source code.
For the primary source file under OS/390 batch,
_ _FILE_ _
expands to the data set name of the source file, if it is a disk
data set, or the DDname allocated to the source file. For the primary source
file under CMS,
_ _FILE_ _
expands to "filename filetype",
where filename is the CMS filename and filetype is the CMS filetype.
For a
#include
or header file, under both OS/390 and CMS,
_ _FILE_ _
expands to the name that appears in the
#include
statement, including the angle brackets or double quotes
as part of the string. Thus, for the following,
_ _FILE_ _
expands
to "\"
myfile.h
\"":
#include "myfile.h"
For the following,
_ _FILE_ _
expands
to "
<myfile h e>
":
#include <myfile h e>
_ _LINE_ _
_ _TIME_ _
hh:mm:ss
(for example,
10:15:30
). Double quotes are a part
of the expansion; no double quotes should surround
_ _TIME_ _
in your source
code.
None of the above
predefined macros can be undefined with the
#undef
directive.
The translator also provides the following predefined
macro names. Automatic predefinition of these names can be collectively suppressed
by using the
undef
translator option. (Refer to Option Descriptions for more information on
undef
.) These
macro names also can be undefined by the
#undef
preprocessor directive.
The following code shows their usage:
#define OSVS 1 // if translating under TSO // or MVS batch #define CMS 1 // if translating under CMS #define I370 1 // indicates the SAS/C // Compiler or the translator #define DEBUG 1 // if the DEBug option is // used #define NDEBUG 1 // if the DEbug option is not used
A few of the predefined macros can only be undefined
by the
#undef
preprocessor
directive. They are not affected by the
undef
translator option. These macros are:
#define _ _COMPILER_ _ "SAS/C C++ 6.50B" // indicates // the current release // as a string #define _ _I370_ _ 1 // indicates the SAS/C // Compiler or the translator #define _ _SASC_ _ 650 // indicates the current // version as a number, // for example, 650
Note:
Because the translator is not a C compiler, the
_ _STDC_ _
macro is not defined.
Language Extensions |
This section describes SAS/C extensions to the language described in The C++ Programming Language.
Note:
Use of these extensions is likely
to render a program nonportable.
For information on SAS/C extensions to the C language,
such as the
_ _asm
keyword, the
_ _alignmem
and
_ _noalignmem
keywords, and keywords used in declarations of functions that are
neither C++ nor C, see the
SAS/C Compiler and Library User's Guide. Also refer to the
SAS/C Compiler and Library User's Guide for a discussion
of the implementation-defined behavior of the SAS/C Compiler.
A"this is an ASCII string"
E"this is an EBCDIC string"
Two
#pragma
directives are
handled by the SAS/C C++
Development System directly:
#pragma linkage #pragma map
These
#pragma
directives are described in the
SAS/C Compiler and Library User's Guide.
In C++ programs, these directives can be applied only to functions and variables
that have
extern
"C" linkage (that is, they are declared in an extern "C" block
or have extern "C" in their declaration).
The
_ _ibmos
SAS/C extension keyword is a simpler
and more direct replacement for
#pragma linkage
. The
_ _ibmos
keyword is described in the SAS/C Compiler and Library User's Guide. AR370 is a simpler and more powerful replacement for
#pragma map
. The AR370 utility is described in the
SAS/C Compiler and Library User's Guide.
All other
#pragma
directives are passed on
directly to the output C file and are otherwise ignored by C++.
// optional comments and newlines #ifndef SOME_SYMBOL // included definitions... #endif // end of file
When a second #include
of the same file is found, the preprocessor can check the specified preprocessor
symbol and avoid rereading the file if the symbol is defined. The recognized
forms of the test are as follows:
#ifndef SYMBOL
or
#if !defined SYMBOL
or
#if !defined(SYMBOL)
You can use the following SAS/C extension keywords in your C++ programs:
_ _asm _ _local _ _weak _ _cobol _ _pascal _ _foreign _ _pli _ _fortran _ _ref _ _ibmos _ _remote
Overloading on these SAS/C extension keywords is supported.
The following example shows overloading
error_trap
to take both local and remote function pointers:
int error_trap(_\x12_local void(*f)()); int error_trap(_\x12_remote void(*f)());
Functions defined using one
or more of the keywords
_ _ibmos
,
_ _asm
, or
_ _ref
must be written in assembler. Therefore, the translator assumes "C" linkage
for these functions, even if extern "C" is not explicitly used. Similarly,
_ _pli
,
_ _cobol
,
_ _fortran
,
_ _pascal
,
and
_ _foreign
functions have linkage appropriate for the language and therefore do not
have C++ linkage. The main effect of this behavior is that overloading the
following functions is not allowed:
_ _asm int myfunc(int); _ _pli int myfunc(int*);
These functions cannot be overloaded because only one linkage version of a function that is not C++ is permitted.
For more information on SASC extension keywords, see
the
SAS/C Compiler and Library User's Guide.
Digraph Sequences for Special Characters lists alternate representations that the translator accepts (this set of digraphs is identical to the digraph set accepted by the SAS/C Compiler). The digraph option(s) chosen determines which alternate forms are used:
See Option Descriptions for more information on digraph options.
The backslash is a special case because it has meaning
within string and character constants as well as within C++ statements. You
can also customize the translator to accept an alternate single character
for the backslash, as well as for other characters in Digraph Sequences for Special Characters . The default alternate
representations are listed in Default Representations for Special Characters . See your SAS Installation Representative
for more information.
The dollar sign ($) can be used
as an embedded character
in identifiers. If the dollar sign is used in identifiers, the
dollars
translator
option must be specified. Use of the dollar sign is not portable because the
dollar sign is not part of the portable C++ character set. The dollar sign
cannot be used as the first character in an identifier; such usage is reserved
for the library.
An extended
format for floating-point constants enables them
to be specified in hexadecimal to indicate the exact bit pattern to be placed
in memory. A hexadecimal
double
constant consists of the sequence
0.x
, followed by 1 to 14 hexadecimal digits. If there are fewer than
14 digits, the number is extended to 14 digits on the right with 0s. A hexadecimal
double
constant defines the exact bit pattern to be used for the constant.
For example,
0.x411
has the same value as
1.0
. Use of this feature is nonportable.
The
@
operator is a language extension provided primarily to aid communication
between C++ and other programs.
One approach to the call-by-reference problem is to precede
each function argument by the
&
operator, thereby passing the
argument address rather than its value. For example, you can write
asmcode(&x)
rather than
asmcode(x)
. This approach is not generally applicable
because it is frequently necessary to pass constants or computed expressions,
which are not valid operands of the address-of operator. The translator provides
an option to solve this problem.
When the translator option
at
is specified, the at sign (
@
) is treated as an operator. The
@
operator can be used only on an
argument to a function call. The result of using it in any other context is
undefined. The
@
operator has the same syntax as the C ampersand
(
&
) operator. In situations
where the C
&
can
be used,
@
has the same meaning as
&
. In addition,
@
can be used
on values that are not lvalues such as constants and expressions. In these
cases, the value of
@
expr is the address of a temporary storage area
to which the value of expr is copied. One special case for the
@
operator
is when its argument is an array name or a string literal. In this case,
@array
is different from
&array
. The latter still addresses the array,
while
@array
addresses a pointer addressing the array. Use of
@
is, of course,
nonportable. Its use should be restricted to programs that call routines,
that are not C++, .using call-by-reference.
When declaring a call by reference instead of using
the
@
notation, you may
want to use the
_ _asm
or
_ _ref
keyword described
in the SAS/C Compiler and Library User's Guide.
If the
redef
translator option is specified,
multiple
#define
statements for the same symbol can appear in a source file. When
a new
#define
statement is encountered for a symbol, the old definition
is stacked but is restored if an #undef statement for the symbol occurs. For
example, if the line
#define XYZ 12
#define XYZ 43
#undef XYZ
To completely undefine XYZ, an additional
#undef
is required. Each
#define
must be matched by a corresponding
#undef
before the symbol is
truly forgotten. Identical
#define
statements for a symbol (those permitted when
redef
is not specified) do not stack.
An array of length 0 can be declared as a member of a
structure
or class. No space is allocated for the array, but the following member is
aligned on the boundary required for the array type. Zero-length arrays are
useful for aligning members to particular boundaries (to match the format
of external data for example) and for allocating varying-length arrays following
a structure. In the following structure definition, no space is allocated
for member
d
, but the member b is aligned on a doubleword boundary:
struct ABC { int a; double d[0]; int b; };
Zero-length arrays are not permitted in any other context.
_ _inline
is a storage class
modifier. It can be used in the
same places as a storage class specifier and can be declared in addition to
a storage class specifier. If a function is declared as
_ _inline
and the module contains at least one definition of the function, the translator
sees this as a recommendation that the function be inlined. If a function
is declared as
_ _inline
and has external linkage, a real
copy of the function is created so that other external functions can call
it.
With the 6.50 release, if you use inline functions and
have
DEBUG
turned off,
the translator performs inlining of inline functions whether the
optimize
option is on or off. If
DEBUG
is turned on, the translator disables
inlining. The
optimize
option is on by default.
_ _actual
is also a storage class modifier.
It can be specified with or without the
_ _inline
qualifier, but
it implies
_ _inline
.
_ _actual
specifies that the translator should
produce an actual (callable) copy of the function if the function has external
linkage. If the function has internal linkage, the translator creates an actual
function unless it does not need one.
For additional information, see the discussion of
_ _inline
and
_ _actual
in the SAS/C Compiler and Library User's
Guide.
Note:
The difference between the
_ _inline
modifier and the
inline
C++ keyword is that the inline keyword causes
inline functions to behave as if they were declared static while
_ _inline
does not. In some cases, current ANSI C++ rules may treat the inline function
as if it has external linkage.
Implementation-Defined Behavior |
limits.h
and
float.h
C header files, are described in the SAS/C Compiler and Library User's Guide.
wchar_t
initializers.
size_t
is
unsigned int
, as it is for the SAS/C Compiler.
ptrdiff_t
is
signed long
.
To summarize, the
bitfield
translator option causes
the translator to accept any integral type in the declaration of a bitfield
and enables you to control the allocation of bitfields. By default, bitfields
are aligned on word boundaries. Plain
int
bitfields are treated as
unsigned
int
bitfields, and the order of allocation of bitfields with an
int
is left to right.
#include
header files are the same as for the SAS/C Compiler. This topic is
discussed in the SAS/C Compiler and Library User's Guide. You
should also refer to Using the SAS/C C++ Development System under TSO, CMS, OS/390 Batch, and UNIX System Services .
#pragma
preprocessing directive is
discussed earlier in this chapter, in C++ Language Definition .
main
is the same as it is for the SAS/C Compiler and complies with
the ANSI definition.
int main(void){ /* ... */ }
Or, it can have two parameters and be defined as
int main(int argc, char *argv[]) { /* ... */ }
C
" and "
C++"
. "
C
" linkage for functions means that type information is not encoded
in the function's identifier. "
C
" linkage does not affect the linkage
for nonfunctions. Remember that the linkage for
main
is always "
C
".
operator new
is responsible for memory allocation;
it does not leave the allocation up to the constructor.
const
object through a non-
const
pointer is unpredictable and could cause an ABEND.
asm
declaration (for example,
asm(str_lit)
) is not allowed by the translator. Do not confuse the use of an
asm
declaration
with the SAS/C
_ _asm
keyword.
static
data members are allocated in the order in
which they are declared.
#include
statements
or for conditional compilation.
When a program containing C++ code is started, file-scope objects defined in C++ translation units in the main load module are initialized in the reverse order of the translation unit's inclusion into the load module by COOL. (For more information on this topic, see INCLUDE Statement .) Within a translation unit, objects are initialized in the order that they are defined in the translation unit.
When the main program ends, either by calling
exit
or by returning from
main
, file-scope objects defined in C++ translation units in the
main load module are terminated in the reverse order of how they were initialized.
Anachronisms |
overload
keyword is supported but
must be enabled
by the
overload
translator option.
overload
is not treated as a reserved
word unless you turn on the
overload
option.
redef
option allows you to nest
#define
statements.
For more details, see Nesting of #define .
this
is not
supported.
operator
++()
can be used to overload both prefix and postfix ++ and a single
function
operator --()
can be used to overload both prefix and postfix
--
. The SAS/C C++ Development System follows the more modern practice
of using different function signatures for overloading the prefix and postfix
forms of these operators.
-Knotmpfunc
for
UNIX System Services and the cross-compiler).
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.