Chapter Contents |
Previous |
Next |
Source Code Conventions |
Source File Sequence Number Handling |
The compiler examines
the first record in the source file and
in each
#include
file to determine if that file contains
sequence numbers. Therefore, you can safely mix files with and without sequence
numbers and use the compiler on sequenced or nonsequenced files without worrying
about specifying a sequence number parameter.
Include-File Processing |
The rest of this section presents include-file processing topics in the following order.
include
directives specify directory paths.
include
directives, but where the include files are
stored in a mainframe file system (for example, a CMS minidisk).
On OS/390, the accepted
forms for a simple
#include
directive are as follows:
#include "member.libddn" #include "style:pathname" #include "//[style:]pathname" #include <member.h> #include <member>
In the first form,
the first part of the filename is interpreted as a member name and the second
part as a DDname. For instance, an include of
"
protos.h
"
will look in DDname H for a PDS member PROTOS.
Note that the DDname H could also reference an USS HFS directory, in which
case the compiler includes the file
protos.h
from that directory.
If the member specified is not found in the DDname specified, the compiler
processes the directive as if the filename were enclosed in angle brackets.
In the example, if the compiler failed to locate
"
protos.h
"
, it would attempt to include
<protos.h>
.
In the second or third form, the filename must be a
valid pathname for a call to
fopen
(see
SAS/C Library Reference, Volume 1). In this case,
the compiler simply includes the file specified. If the file cannot be opened,
the compilation fails.
Note that if the underscore character (_) appears in the member
or libddn part of an include filename, it is translated to a
pound sign (#) wherever it occurs, except when including from an HFS directory.
For instance, including
"
name_1.my_lib
"
would fetch the member NAME#1 from the PDS referenced by the DDname MY#LIB.
Also note that if the member name or libddn name is longer than
eight characters, it is truncated.
On
CMS, the accepted forms for a simple
#include
directive are
as follows:
#include "filename.filetype" #include "style:pathname" #include "//[style:]pathname" #include <member.h> #include <member>
In the first form,
the filename is interpreted as a CMS filename and filetype and located on
an ACCESSed minidisk. For instance, an include of
"
protos.h
"
will search all ACCESSed minidisks for the file
PROTOS H. If the file specified cannot be found, the compiler processes the
directive as if the filename were enclosed in angle brackets. In the example,
if the compiler failed to locate
"
protos.h
"
, it would attempt to include
<protos.h>
.
In the second and third forms, the filename must be
a valid pathname for a call to
fopen
(see
SAS/C Library Reference, Volume 1).
In this case, the compiler simply includes the file specified. If the file
cannot be opened, the compilation fails.
Note that if a member name or filename component is
longer than eight characters, it is truncated.
Under
the USS shell, the accepted forms for a simple
#include
directive are
as follows:
#include "pathname" #include "//[style:]pathname" #include <member.h>
In the first form,
the filename is interpreted as an HFS filename in the same directory as the
including file. For instance, an include of
"
protos.h
"
in the source program will search the source directory
for the file
protos.h
. If the file specified cannot be found,
the compiler processes the directive as if the file were enclosed in angle
brackets. In the example, if the compiler failed to locate
"
protos.h
"
, it would attempt to include
<protos.h>
.
In the second form, the filename must be a valid pathname
for a call to
fopen
(see
SAS/C Library Reference, Volume 1). In this case, the compiler
simply includes the file specified. If the file cannot be opened, the compilation
fails.
Note that complex applications may require the use of
the
ipath
compiler option to augment these simple search
rules. This option is discussed in Complete include processing.
Many
existing programs written for other environments such as UNIX contain
#include
directives which reference directories or which have long
filenames that are not unique within the first eight characters. Since the
OS/390 and CMS file systems do not support directories or filename components
longer than eight characters, these files could not be stored on the mainframe
without being renamed and/or reorganized. Header file mapping was developed
for the SAS/C Compiler to allow the
portable source for these applications to be used despite the deficiencies
of the mainframe file systems.
Before
opening any include
file, the compiler attempts to open a $$HDRMAP file. If the include file
is a system header file, the header map file is found like
<$$hdrmap.h>
(that is, on OS/390 it is the $$HDRMAP member of SYSLIB, and on CMS
it is the $$HDRMAP member of the GLOBALed MACLIBs). Similarly, if the include
file is a user include file, the compiler looks for $$HDRMAP as if it were
included as
"
$$hdrmap.h
"
. Note that on OS/390
the libddn part of the original user include filename is ignored,
and $$HDRMAP is always fetched from the DDname H.
Note that $$HDRMAP is processed for any
include
directive, even if the filename does not include a directory
specification.
X11/AtomMgr.h XATMGR.H X11R5 header
The first name is the expected header filename. The
filename from a compiled
#include
directive is compared with
the header name in each $$HDRMAP line until a matching line is found. The
names must match exactly. For example,
"./X11/AtomMgr.h"
and
"X11/AtomMgr.h"
are not considered to match. If the compiled filename
does match the first name of a header map line, the compiler replaces it with
the second string on the line and proceeds to search for that file using the
rules described in Include-File Processing.
Thus, on OS/390, a
#include
directive for
"X11/AtomMgr.h"
would attempt to include the member XATMGR in the DDname H.
Note that a target filename in the $$HDRMAP file should
not be bracketed or quoted. The type of file (system or user) is always assumed
to be the same as in the original
#include
directive. Also
note that if the search for a user header file (whether the name is mapped
or not) fails, the system $$HDRMAP file is used to map the name before the
system header file location is searched. Therefore, the order of steps for
a user header file is as follows:
Assume the following system header file map (SYSLIB($$HDRMAP) on OS/390):
X11/AtomMgr.h XATMGR.H X11/Xlibos.h XLIBOS.H ../mydir/george.h GEORGE.MYDIR
and the following user header file map (H($$HDRMAP) on OS/390):
MyVeryLongName.h MVLN.H ../mydir/myfile.h MYFILE.MYDIR
Then, the following
#include
directives would be processed as follows:
#include "
../mydir/myfile.h
"
#include "
../mydir/george.h
"
#include <X11/Xlibos.h>
#chain FILENAME |
When the
#chain
command is specified in a $$HDRMAP file, the header-map lookup
uses the
#include
processing rules specified
on this compilation to locate the file named FILENAME. It uses
system include rules when processing system $$HDRMAP files and user include
rules for user defined $$HDRMAP files.
Any header-map entries found in the file will be inserted
in the list at the point of the
#chain
command.
A file that is processed using a
#chain
can
#chain
other files. If
the file named on the
#chain
cannot be
located or opened using the include search rules, the
#chain
is ignored and processing continues.
For example, in a user include $$hdrmap.h, you could have
foo.h bar.h harry.h george.h # # Go get the mappings for the current project. # #chain //DDN:PROJECT(MAPPINGS) alice.h betty.h
If the DDN "PROJECT" was defined so that MAPPINGS contained
somebiglongname.h sbln.h
Then the header map list would be :
foo.h --> bar.h harry.h --> george.h somebiglongname.h --> sbln.h alice.h --> betty.h
To deal with the complexities introduced by HFS directories
and to provide a high level of compatibility with UNIX include-file processing,
the compiler offers the
ipath
and
usearch
options. Additionally,
on CMS the _HEADERS environment variable provides additional flexibility for
users of the CMS shared file system. Refer to Using Environment Variables to Specify Defaults for information on the _HEADERS environment
variable.
The
usearch
option specifies "UNIX search
rules," which is a rearrangement of the compiler's normal methods of processing
for greater UNIX compatibility.
usearch
is the default
when you compile under the USS shell, but it may be specified for compiles
from other environments. The
ipath
option allows you
to specify one or more locations to be searched for header files. These are
normally HFS directories, but they could also be PDS names or CMS shared file
system directories.
If the
usearch
option is not in effect, the
order of include processing for a
#include
of a user (double-quoted)
header file is as follows. (Note that if any step locates the file, the remaining
steps are not performed.)
ipath
options are searched for the header file, in the order in which they were
specified.
include
directive was obtained from an HFS directory, the compiler searches
this directory.
If the
usearch
option is not in effect, the
order of processing for a system (bracketed) include file is as follows.
(Note that if any step locates the file, the remaining steps are not performed.)
If the
usearch
option is specified to enforce
UNIX search rules, the search for a user (double-quoted) include file proceeds
as follows. (Note that if any step locates the file, the remaining steps are
not performed.)
ipath
options are searched for the header file, in the order in which they were
specified.
If the
usearch
option is specified to enforce
UNIX search rules, the search for a system (bracketed) include file proceeds
as follows. (Note that if any step locates the file, the remaining steps are
not performed.)
ipath
options are searched for the header file, in the order in which they were
specified.
The primary differences between the UNIX (
usearch
) search rules and the ordinary SAS/C (
nousearch
) search rules are the following:
usearch
is in effect, the
locations specified by
ipath
are searched for both user and
system header files. When
usearch
is not in effect,
ipath
is used only to search for user header files.
usearch
is in effect, the
including file's directory is searched before the
ipath
directories. When
usearch
is not in effect, the
ipath
directories are searched
before the directory of the including file.
usearch
is in effect, the
location of the including file is always searched. When
usearch
is not in effect, it is searched only if the including file was obtained
from the HFS.
usearch
is not in effect
and the compiler is running under the shell, an explicit search of the current
directory is performed before the system-dependent search. This step is not
performed when
usearch
is in effect.
Multibyte Character Support |
A wide character is a value of type
wchar_t
, which the compiler defines as
unsigned short
. If the
value is in the range of the
char
type, it represents a standard
EBCDIC character. If the value is outside the range of
char
,
it represents an extended character, such as a character of the Japanese Kanji
character set. EBCDIC DBCS constrains each byte of a wide character outside
the range of
char
to have a value between 0x40 and 0xFE.
All instances of DBCS in C source are in mixed strings.
For string literals (including array initializers) and character constants,
an L prefix controls whether or not the type of the literal or constant is
based on
char
or
wchar_t
.
There are two kinds of character constants:
integral and wide. Wide character constants are prefixed by the letter L.
Integral character constants have type
int
; wide character constants
have type
wchar_t
. In the SAS/C implementation,
wchar_t
is an
unsigned short
.
wchar_t
value, using its
rightmost bits; any excess bits are ignored.
The implementation of string literals and wide string
literals is nearly identical to that of character constants. The type of a
wide string literal is interpreted as an array of
wchar_t
. The compiler issues
a warning message for attempts to use adjacent string concatenation with different
types of string literals and gives the type for the first literal in the concatenation.
(The ISO/ANSI Standard treats this as undefined.)
A wide string literal may be used to
initialize an array of elements whose type is
wchar_t
. Both static
and auto array initialization are supported.
Special Character Support |
Trigraph sequences are an invention of the C standardization committee.
They are intended to serve as replacements for characters in the C character
set that do not appear in the ISO 646 character set. See the
trigraphs
option in Compiler Options for information about trigraphs.
Digraph Sequences For Special Characters gives alternate representations that the compiler accepts.
The backslash is a special case because it has significance within string and character constants as well as within C statements. However, the compiler can be customized to accept an alternate single character for the backslash. In addition, the customization can include alternate single character representations of the characters in Digraph Sequences For Special Characters. The default alternate representations are listed in Default Representations for Special Characters. See your SAS Software Representative for C compiler products for more information.
Note that in addition to the digraphs described in
Digraph Sequences For Special Characters, your
site can customize the compiler to accept alternate single-character representations
of the characters. See your site representative for details.
The special characters that can be customized are braces ({}), square brackets ([]), not sign (¬), tilde (~), backslash (), the vertical bar (|), the exclamation point (!), and the pound sign (#). You should determine if your site has customized values for these characters and determine values. Otherwise, the default representations listed in Default Representations for Special Characters are in effect. Consult your SAS Software Representative for C compiler products for details of customized values.
Default Representations for Special Characters shows the four possible default representations for each character. The compiler and OMD (object module disassembler) accept either of two representations of the character in a source file. These are the primary and alternate representations in columns two and three. The compiler and OMD can produce either of two representations of each character in a listing file depending on the execution options specified. The first is the standard print representation shown in column four. The second, the overstrike representation listed in column five, is produced by overstriking the character with another character. (Details about the execution options and how they interact are provided in Compiler Options.) The entries in columns two through five are EBCDIC equivalents of the characters in hexadecimal notation.
In addition to the problem of entering C source text
on devices that do not have the full character set, there is also the problem
of printing the text. The compiler supports two options to assist in this
area: the
trans
option and the
upper
option. See Compiler Options for more information
on these options.
Escape Sequences |
The
compiler produces a unique
char
value for certain alphabetic
escape sequences that represent nongraphic characters. The characters' associated
hex values and ISO/ANSI meaning appear in Escape Sequence Values.
Sequence | Hex Value | Meaning |
---|---|---|
\a | 0x2f | alert |
\b | 0x16 | backspace |
\f | 0x0c | form feed |
\n | 0x15 | new line |
\r | 0x0d | carriage return |
\t | 0x05 | horizontal tab |
\v | 0x0b | vertical tab |
Translation Limits |
Wherever possible, the compiler avoids imposing
fixed translation
limits. The ISO/ANSI Standard translation limits for which the compiler does
impose a fixed limit are listed in Integral Type Sizes, followed by some other limits of practical
interest. If no limit is listed, the only limit is imposed by the memory
available to the compiler or by the program when it is executed. The
extname
option can override the following translation limits for internal
and external identifiers and allow 64K characters of significance:
#include
file nesting is
16.
Storage Class Limits |
Note that the following types of programs generate very large CSECTS:
norent
option and with large amounts of static or defined external data or both
rentext
option and with large amounts of static
data.
You should consider alternatives to using large amounts
of static data (for example, dynamic storage allocation via
malloc
).
Storage allocated via the
malloc
family of routines
is limited only by available memory.
Numerical Limits |
The numerical limits are what you would expect for a 32-bit, two's 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 |
For more details on the implementation of the various data types, see Code Generation Conventions.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.