Chapter Contents |
Previous |
Next |
Porting UNIX Socket Applications to the SAS/C Environment |
The SAS/C Library also supports the
#pragma map
statement, which directs the compiler
to change an external name in the source to a different name in the object
file. Thus, long names are shortened, and names that are not lexically valid
in C language can be generated. The socket library header files change long
socket function names by including
#pragma map
. For example, the
<netdb.h>
header file contains the following statement:
#pragma map (gethostbyname, "#GHBNM")
This statement changes the
gethostbyname
function to
#GHBNM
. The
#pragma map
statement enables you to use TCP/IP functions with long names in your
source and does not require that you use the extended names option or the
COOL utility.
#pragma
map
statements are already in the header files required for each function.
You normally do not have to modify your source to accommodate long names.
If your program produces an unresolved external reference for a socket function containing a long name, first make sure that you have included the appropriate header files as listed in the description for each socket function in Socket Function Reference. The following header files are not always required by UNIX C compilers but are required by the SAS/C Compiler to resolve long names:
<arpa/inet.h>
header file with the
inet_*
functions, such as
inet_addr
. This is correct coding practice but is not
required by UNIX
C compilers. As a compatibility feature, the SAS/C Library file
<netinet/in.h>
includes the
<arpa/inet.h>
file.
<netdb.h>
header file with the
gethostid
and
gethostname
functions. This is not required by
UNIX C compilers. To reduce incompatibilities
caused by failure to include the
<netdb.h>
header file in existing source code,
#pragma map
statements for these functions are
also available in the
<sys/types.h>
header file.
<socket.h>
,
<netdb.h>
,
<resolv.h>
,
and
<nameser.h>
header
files all contain
#pragma map
statements for the functions that require them. Most UNIX programs
include these headers with the appropriate functions.
The functions in most programs ported from a UNIX operating
system have long names. If a function in your program contains a long name,
use the
extname
name compiler
option and the COOL utility to compile and link your program. The effects
of both the
#pragma map
statement and the
extname
option are not usually visible to the user. For information on the significance
of these features during machine-level debugging, reading link-edit maps,
and writing zaps, refer to Appendix 7, "Extended Names," in the SAS/C
Compiler and Library User's Guide.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.