Documentation Home
> Sun WorkShop Compiler C 5.0 User's Guide
Sun WorkShop Compiler C 5.0 User's Guide
Book Information
Preface
Chapter 1 Introduction to the C Compiler
Standards Conformance
Organization of the Compiler
C-Related Programming Tools
Chapter 2 cc Compiler Options
Option Syntax
The cc Options
-#
-###
-Aname[(tokens)]
-B[static|dynamic]
-C
-c
-Dname[=tokens]
-d[y|n]
-dalign
-E
-erroff=t
-errtags=a
-fast
-fd
-flags
-fnonstd
-fns[={no,yes}]
-fprecision=<p>
-fround=r
-fsimple[=n]
-fsingle
-fstore
-ftrap=t
-G
-g
-H
-h name
-Idir
-i
-keeptmp
-KPIC
-Kpic
-Ldir
-lname
-mc
-misalign
-misalign2
-mr
-mr,string
-mt
-native
-nofstore
-noqueue
-O
-o filename
-P
-p
-Q[y|n]
-qp
-Rdir[:dir]
-S
-s
-Uname
-V
-v
-Wc,arg
-w
-X[a|c|s|t]
-x386
-x486
-xa
-xarch=a
-xautopar
-xcache=c
-xCC
-xcg[89|92]
-xchip=c
-xcode=v
-xcrossfile[=n]
-xdepend
-xe
-xexplicitpar
-xF
-xhelp=f
-xildoff
-xildon
-xinline=[f1,...,fn]
-xlibmieee
-xlibmil
-xlic_lib=l
-xlicinfo
-xloopinfo
-xM
-xM1
-xMerge
-xmaxopt=<off, 1, 2, 3, 4, 5>
-xnolib
-xnolibmil
-xO[1|2|3|4|5]
-xP
-xparallel
-xpentium
-xpg
-xprefetch[={yes|no}]
-xprofile=p
-xreduction
-xregs=r
-xrestrict=f
-xs
-xsafe=mem
-xsb
-xsbfast
-xsfpconst
-xspace
-xstrconst
-xtarget=t
-xtemp=dir
-xtime
-xtransition
-xunroll=n
-xvpara
-Yc, dir
-YA, dir
-YI, dir
-YP, dir
-YS, dir
-Zll
-Zlp
Options Passed to the Linker
Chapter 3 Sun ANSI/ISO C Compiler-Specific Information
Environment Variables
TMPDIR
SUNPRO_SB_INIT_FILE_NAME
PARALLEL
Global Behavior: Value versus unsigned Preserving
Keywords
asm Keyword
_Restrict Keyword
long long Data Type
Printing long long Data Types
Usual Arithmetic Conversions
Constants
Integral Constants
Character Constants
Include Files
Nonstandard Floating Point
Preprocessing Directives
Assertions
Pragmas
#pragma align integer (variable[, variable])
#pragma does_not_read_global_data (funcname [, funcname])
#pragma does_not_return (funcname [, funcname])
#pragma does_not_write_global_data (funcname [, funcname])
#pragma error_messages (on|off|default, tag... tag)
#pragma fini (f1[, f2...,fn])
#pragma ident string
#pragma init (f1[, f2...,fn])
#pragma inline (funcname[, funcname])
#pragma int_to_unsigned (funcname)
(SPARC) #pragma MP serial_loop
(SPARC) #pragma MP serial_loop_nested
(SPARC) #pragma MP taskloop
#pragma no_inline (funcname[, funcname])
(SPARC) #pragma nomemorydepend
(SPARC) #pragma no_side_effect (funcname)
#pragma optlevel (funcname[, funcname])
#pragma pack(n)
(SPARC) #pragma pipeloop(n)
#pragma rarely_called(funcname[, funcname])
#pragma redefine_extname old_extname new_extname
#pragma returns_new_memory (funcname[, funcname])
#pragma unknown_control_flow (name[, name])
(SPARC) #pragma unroll (unroll_factor)
#pragma weak (symbol1 [= symbol2])
Predefined Names
MP C (SPARC)
Overview
Example of Use
Environment Variable
Keyword
Explicit Parallelization and Pragmas
Serial Pragmas
Parallel Pragmas
Nesting of for loops
Eligibility for Parallelizing
Number of Processors
Classifying Variables
Default Scoping Rules for Private and Shared Variables
Private Variables
Shared Variables
Read-only Variables
Storeback Variables
Savelast
Reduction Variables
Scheduling Control
Compiler Options
Chapter 4 cscope:Interactively Examining a C Program
The cscope Process
Basic Use
Step 1: Set Up the Environment
Step 2: Invoke the cscope Program
Step 3: Locate the Code
Step 4: Edit the Code
Command-Line Options
View Paths
cscope and Editor Call Stacks
Examples
Changing a Constant to a Preprocessor Symbol
Adding an Argument to a Function
Changing the Value of a Variable
Command-Line Syntax for Editors
Unknown Terminal Type Error
SourceBrowser
Chapter 5 lint Source Code Checker
Basic and Enhanced lint Modes
Using lint
The lint Options
-#
-###
-a
-b
-C filename
-c
-dirout=dir
-err=warn
-errchk=l(, l)
%all
%none
longptr64
no%longptr64
no%structarg
parentheses
sizematch
structarg
-errfmt=f
-errhdr=h
-erroff=tag(, tag)
-errtags=a
-F
-fd
-flagsrc=file
-h
-Idir
-k
-Ldir
-lx
-m
-Ncheck=c
-Nlevel=n
-Nlevel=1
-Nlevel=2
-Nlevel=3
-Nlevel=4
-n
-ox
-p
-Rfile
-s
-u
-V
-v
-Wfile
-x
-XCC=a
-Xarch=v9
-Xexplicitpar=a
-Xkeeptmp=a
-Xtemp=dir
-Xtime=a
-Xtransition=a
-y
lint Messages
Options to Suppress Messages
lint Message Formats
lint Directives
Predefined Values
Directives
lint Reference and Examples
Checks Performed by lint
Consistency Checks
Portability Checks
Questionable Constructs
lint Libraries
lint Filters
Appendix A ANSI/ISO C Data Representations
Storage Allocation
Data Representations
Integer Representations
Floating-Point Representations
Exceptional Values
Hexadecimal Representation of Selected Numbers
Pointer Representation
Array Storage
Arithmetic Operations on Exceptional Values
Argument-Passing Mechanism
Appendix B Implementation-Defined Behavior
Implementation Compared to the ANSI/ISO StandardT
Translation (G.3.1)
(5.1.1.3) Identification of diagnostics:
Environment (G.3.2)
(5.1.2.2.1) Semantics of arguments to main:
(5.1.2.3) What constitutes an interactive device:
Identifiers (G.3.3)
(6.1.2) The number of significant initial characters (beyond 31) in an identifier without external linkage:
(6.1.2) The number of significant initial characters (beyond 6) in an identifier with external linkage:
Characters(G.3.4)
(5.2.1)The members of the source and execution character sets, except as explicitly specified in the Standard:
(5.2.1.2)The shift states used for the encoding of multibyte characters:
(5.2.4.2.1)The number of bits in a character in the execution character set:
(6.1.3.4)The mapping of members of the source character set (in character and string literals) to members of the execution character set:
(6.1.3.4)The value of an integer character constant that contains a character or escape sequence not represented in the basic execution character set or the extended character set for a wide character constant:
(3.1.3.4)The value of an integer character constant that contains more than one character or a wide character constant that contains more than one multibyte character:
(6.1.3.4)The current locale used to convert multibyte characters into corresponding wide characters (codes) for a wide character constant:
(6.2.1.1)Whether a plain char has the same range of values as signed char or unsigned char:
Integers(G.3.5)
(6.1.2.5)The representations and sets of values of the various types of integers:
(6.2.1.2)The result of converting an integer to a shorter signed integer, or the result of converting an unsigned integer to a signed integer of equal length, if the value cannot be represented:
(6.3)The results of bitwise operations on signed integers:
(6.3.5)The sign of the remainder on integer division:
(6.3.7)The result of a right shift of a negative-valued signed integral type:
Floating-Point(G.3.6)
(6.1.2.5)The representations and sets of values of the various types of floating-point numbers:
(6.2.1.3)The direction of truncation when an integral number is converted to a floating-point number that cannot exactly represent the original value:
(6.2.1.4)The direction of truncation or rounding when a floating- point number is converted to a narrower floating-point number:
Arrays and Pointers(G.3.7)
(6.3.3.4, 7.1.1)The type of integer required to hold the maximum size of an array; that is, the type of the sizeof operator, size_t:
(6.3.4)The result of casting a pointer to an integer, or vice versa:
(6.3.6, 7.1.1)The type of integer required to hold the difference between two pointers to members of the same array, ptrdiff_t:
Registers(G.3.8)
(6.5.1)The extent to which objects can actually be placed in registers by use of the register storage-class specifier:
Structures, Unions, Enumerations, and Bit-Fields(G.3.9)
(6.3.2.3)A member of a union object is accessed using a member of a different type:
(6.5.2.1)The padding and alignment of members of structures.
(6.5.2.1)Whether a plain int bit-field is treated as a signed int bit-field or as an unsigned int bit-field:
(6.5.2.1)The order of allocation of bit-fields within an int:
(6.5.2.1)Whether a bit-field can straddle a storage-unit boundary:
(6.5.2.2)The integer type chosen to represent the values of an enumeration type:
Qualifiers(G.3.10)
(6.5.5.3)What constitutes an access to an object that has volatile-qualified type:
Declarators(G.3.11)
(6.5.4)The maximum number of declarators that may modify an arithmetic, structure, or union type:
Statements(G.3.12)
(6.6.4.2)The maximum number of case values in a switch statement:
Preprocessing Directives(G.3.13)
(6.8.1)Whether the value of a single-character character constant in a constant expression that controls conditional inclusion matches the value of the same character constant in the execution character set:
(6.8.1)Whether such a character constant may have a negative value:
(6.8.2)The method for locating includable source files:
(6.8.2)The support of quoted names for includable source files:
(6.8.2)The mapping of source file character sequences:
(6.8.6)The behavior on each recognized #pragma directive:
(6.8.8)The definitions for __DATE__ and __TIME__ when, respectively, the date and time of translation are not available:
Library Functions(G.3.14)
(7.1.6)The null pointer constant to which the macro NULL expands:
(7.2)The diagnostic printed by and the termination behavior of the assert function:
(7.3.1) The sets of characters tested for by the isalnum, isalpha, iscntrl, islower, isprint, and isupper functions:
(7.5.1) The values returned by the mathematics functions on domain errors:
(7.5.1) Whether the mathematics functions set the integer expression errno to the value of the macro ERANGE on underflow range errors:
(7.5.6.4) Whether a domain error occurs or zero is returned when the fmod function has a second argument of zero:
(7.7.1.1) The set of signals for the signal function:
(7.7.1.1) The default handling and the handling at program startup for each signal recognized by the signal function:
(7.7.1.1) If the equivalent of signal(sig, SIG_DFL); is not executed prior to the call of a signal handler, the blocking of the signal that is performed:
(7.7.1.1) Whether the default handling is reset if the SIGILL signal is received by a handler specified to the signal function:
(7.9.2) Whether the last line of a text stream requires a terminating new-line character:
(7.9.2) Whether space characters that are written out to a text stream immediately before a new-line character appear when read in:
(7.9.2) The number of null characters that may be appended to data written to a binary stream:
(7.9.3) Whether the file position indicator of an append mode stream is initially positioned at the beginning or end of the file:
(7.9.3) Whether a write on a text stream causes the associated file to be truncated beyond that point:
(7.9.3) The characteristics of file buffering:
(7.9.3) Whether a zero-length file actually exists:
(7.9.3) The rules for composing valid file names:
(7.9.3) Whether the same file can be open multiple times:
(7.9.4.1) The effect of the remove function on an open file:
(7.9.4.2) The effect if a file with the new name exists prior to a call to the rename function:
(7.9.6.1) The output for %p conversion in the fprintf function:
(7.9.6.2) The input for %p conversion in the fscanf function:
(7.9.6.2) The interpretation of a - character that is neither the first nor the last character in the scan list for %[ conversion in the fscanf function:
Locale-Specific Behavior(G.4)
(7.12.1) The local time zone and Daylight Savings Time:
(7.12.2.1) The era for the clock function
(5.2.1) The content of the execution character set, in addition to the required members:
(5.2.2) The direction of printing:
(7.1.1) The decimal-point character:
(7.3) The implementation-defined aspects of character testing and case mapping functions:
(7.11.4.4) The collation sequence of the execution character set:
(7.12.3.5) The formats for time and date:
Appendix C -Xs Differences Between Sun C and ANSI/ISO C
Appendix D Performance Tuning (SPARC)
Limits
libfast.a Library
Appendix E Transitioning to ANSI/ISO C
Basic Modes
A Mixture of Old- and New-Style Functions
Writing New Code
Updating Existing Code
Mixing Considerations
Functions with Varying Arguments
Promotions: Unsigned Versus Value Preserving
Background
Compilation Behavior
First Example: The Use of a Cast
Bit-fields
Second Example: Same Result
Integral Constants
Third Example: Integral Constants
Tokenization and Preprocessing
ANSI/ISO C Translation Phases
Old C Translation Phases
Logical Source Lines
Macro Replacement
Using Strings
Token Pasting
const and volatile
Types, Only for lvalue
Type Qualifiers in Derived Types
const Means readonly
Examples of const Usage
volatile Means Exact Semantics
Examples of volatile Usage
Multibyte Characters and Wide Characters
Asian Languages Require Multibyte Characters
Encoding Variations
Wide Characters
Conversion Functions
C Language Features
Standard Headers and Reserved Names
Balancing Process
Standard Headers
Names Reserved for Implementation Use
Names Reserved for Expansion
Names Safe to Use
Internationalization
Locales
The setlocale() Function
Changed Functions
New Functions
Grouping and Evaluation in Expressions
Definitions
The K&R C Rearrangement License
The ANSI/ISO C Rules
The Parentheses
The As If Rule
Incomplete Types
Types
Completing Incomplete Types
Declarations
Expressions
Justification
Examples
Compatible and Composite Types
Multiple Declarations
Separate Compilation Compatibility
Single Compilation Compatibility
Compatible Pointer Types
Compatible Array Types
Compatible Function Types
Special Cases
Composite Types
Appendix F Converting Applications
Overview of the Data Model Differences
Implementing Single Source Code
Derived Types
<sys/types.h>
<inttypes.h>
Fixed-Width Integer Types
Helpful Types Such as uninptr_t
Constant Macros
Limits
Format String Macros
Tools
lint
Converting to the LP64 Data Type Model
Integer and Pointer Size Change
Integer and Long Size Change
Sign Extension
Pointer Arithmetic Instead of Address Arithmetic
Structures
Unions
Type Constants
Beware of Implicit Declarations
sizeof( ) is an Unsigned Long
Use Casts to Show Your Intentions
Check Format String Conversion Operation
Other Considerations
Derived Types That Have Grown in Size
Check for Side Effects of Changes
Check Whether Literal Uses of long Still Make Sense
Use #ifdef for Explicit 32-bit Versus 64-bit Prototypes
Calling Convention Changes
Algorithm Changes
Checklist for Getting Started
Appendix G K&R Sun C / Sun ANSI/ISO C Differences
K&R Sun C Incompatibilities with Sun ANSI/ISO C
Keywords
© 2010, Oracle Corporation and/or its affiliates