Chapter Contents

Previous

Next
Introduction to the SAS/C Library

Library Header Files

The functions provided by the library are associated with header files. Each header file contains the function prototype and any necessary types and macros associated with the functions. In some cases, the correct use of a function may require more than one header file.

For maximum portability and efficiency, always include the header files for all of the library functions called in a compilation. This practice has two benefits:


Header File Organization

The SAS/C library defines a strict separation of functions into three parts:

Functions defined by the ISO/ANSI standard are declared in the header file mandated by the standard. For example, the fopen function is declared in <stdio.h> . The names of the standard header files are
<assert.h> <setjmp.h>
<ctype.h> <signal.h>
<errno.h> <stdarg.h>
<float.h> <stddef.h>
<limits.h> <stdio.h>
<local.h> <stdlib.h>
<math.h> <string.h>
<time.h>

Functions defined by another standard are declared in the header file mandated by the standard. If that file is also an ISO/ANSI C standard header file, you must use a feature test macro to make the declaration visible. Feature test macros are described in more detail in the next section.

Functions which are not defined by the ISO/ANSI Standard but which are related to standard functions are declared in separate header files. These header filenames are similar to the Standard names but have the prefix lc . For example, the function afopen is declared in <lcio.h> . The names of these header files are
<lcdef.h> <lcmath.h>
<lcio.h> <lcsignal.h>
<lcjmp.h> <lcstring.h>
<lclib.h> <lctype.h>

This separation of functions is intended as an aid in writing portable programs. Only those functions declared in the standard header files are completely portable.

If you include the lc- header file, you do not need to include the standard header file. In all cases, the lc- prefixed header contains a #include statement for the standard header file. For example, the header file <lcstring.h> contains the statement #include <string.h> . (It is not an error to explicitly include both files.) The SAS/C library contains many nonstandard functions and header files that are not associated with standard features. For details on nonstandard functions and header files that are not associated with standard features, see SAS/C Library Reference, Volume 2.

Feature Test Macros

Feature test macros are defined by various IEEE POSIX standards to enable you to specify the standards and language features that you wish to use. SAS/C uses feature test macros in the following way:

SAS/C supports the following feature test macros. To enable a feature, you must define the macro before including any header file, either by using a #define statement or by using the define compiler option.

_SASC_POSIX_SOURCE
If this macro is defined as any value, symbols defined by a supported POSIX.1 standard will be made visible in ISO/ANSI standard header files. _SASC_POSIX_SOURCE has no effect on non-ISO/ANSI header files.

_POSIX_SOURCE
If this macro is defined as any value, symbols defined by the POSIX.1 standard will be made visible in ISO/ANSI standard header files. Also, declarations of any symbols that are not specified as allowable in POSIX.1-header files in the POSIX.1 standard will be suppressed. _POSIX_SOURCE should be defined only for programs which are intended to be POSIX-conforming and which do not use any non-ISO/ANSI or non-POSIX library features.

_POSIX1_SOURCE
If this macro is defined as 1, the effect is the same as defining _POSIX_SOURCE . If this macro is defined as 2, symbols sanctioned by the POSIX.1a draft standard related to features implemented by USS OS/390 will also be made visible. Like _POSIX_SOURCE , _POSIX1_SOURCE should not be defined in any program that uses non-ISO/ANSI non-POSIX features.

_POSIX_C_SOURCE
If this macro is defined as 2, it has the effect of defining _POSIX_SOURCE , plus making visible symbols sanctioned by the POSIX.2 draft standard related to features implemented by SAS/C. If _POSIX_C_SOURCE is defined to any other value, it has the same effect as defining _POSIX_SOURCE . Like _POSIX_SOURCE , _POSIX_C_SOURCE should not be defined in any program that uses non-ISO/ANSI non-POSIX features.

If you use the POSIX compiler option, the feature test macro _SASC_POSIX_SOURCE is automatically defined. This does not ensure that your program is POSIX compliant; it only makes visible POSIX symbols in ISO/ANSI standard header files.


Chapter Contents

Previous

Next

Top of Page

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