DOMAIN C Compiler Software Release Document
Software Release 10.0
Part No. 05570-B01
This document describes the SR10 Domain C Compiler
APOLLO COMPUTER INC.
330 Billerica Road
Chelmsford, Massachusetts 01824
Confidential and Proprietary. Copyright 1988 Apollo Computer, Inc.,
Chelmsford, Massachusetts. Unpublished -- rights reserved under the
Copyright Laws of the United States. All rights reserved.
First Printing: November, 1987
Latest Printing: July, 1988
This document was formatted using the FMT tool distributed with the Domain
computer system.
Apollo and Domain are registered trademarks of Apollo Computer Inc.
UNIX is a registered trademark of AT&T in the USA and other countries. Ada
is a registered trademark of U.S. Government (Ada Joint Program Office).
3DGMR, Aegis, D3M, DGR, Domain/Access, Domain/Ada, Domain/Bridge, Domain/C,
Domain/ComController, Domain/CommonLISP, Domain/CORE, Domain/Debug,
Domain/DFL, Domain/Dialogue, Domain/DQC, Domain/IX, Domain/Laser-26,
Domain/LISP, Domain/PAK, Domain/PCC, Domain/PCI, Domain/SNA, Domain X.25,
DPSS, DPSS/Mail, DSEE, FPX, GMR, GPR, GSR, NLS, Network Computing Kernel,
Network Computing System, Network License Server, Open Dialogue, Open
Network Toolkit, Open System Toolkit, Personal Supercomputer, Personal Super
Workstation, Personal Workstation, Series 3000, Series 4000, Series 10000,
and VCD-8 are trademarks of Apollo Computer Inc.
Apollo Computer Inc. reserves the right to make changes in specifications
and other information contained in this publication without prior notice,
and the reader should in all cases consult Apollo Computer Inc. to determine
whether any such changes have been made.
THE TERMS AND CONDITIONS GOVERNING THE SALE OF APOLLO COMPUTER INC. HARDWARE
PRODUCTS AND THE LICENSING OF APOLLO COMPUTER INC. SOFTWARE PROGRAMS CONSIST
SOLELY OF THOSE SET FORTH IN THE WRITTEN CONTRACTS BETWEEN APOLLO COMPUTER
INC. AND ITS CUSTOMERS. NO REPRESENTATION OR OTHER AFFIRMATION OF FACT
CONTAINED IN THIS PUBLICATION, INCLUDING BUT NOT LIMITED TO STATEMENTS
REGARDING CAPACITY, RESPONSE-TIME PERFORMANCE, SUITABILITY FOR USE OR
PERFORMANCE OF PRODUCTS DESCRIBED HEREIN SHALL BE DEEMED TO BE A WARRANTY BY
APOLLO COMPUTER INC. FOR ANY PURPOSE, OR GIVE RISE TO ANY LIABILITY BY APOLLO
COMPUTER INC. WHATSOEVER.
IN NO EVENT SHALL APOLLO COMPUTER INC. BE LIABLE FOR ANY INCIDENTAL,
INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING BUT NOT
LIMITED TO LOST PROFITS) ARISING OUT OF OR RELATING TO THIS PUBLICATION OR
THE INFORMATION CONTAINED IN IT, EVEN IF APOLLO COMPUTER INC. HAS BEEN
ADVISED, KNEW OR SHOULD HAVE KNOWN OF THE POSSIBILITY OF SUCH DAMAGES.
THE SOFTWARE PROGRAMS DESCRIBED IN THIS DOCUMENT ARE CONFIDENTIAL INFORMATION
AND PROPRIETARY PRODUCTS OF APOLLO COMPUTER INC. OR ITS LICENSORS.
Reader_Notice
This document resides online in the /doc directory. To print a copy of this
document, use the prf command with the -npag and -pr options.
prf <file_pathname> -pr <printer_name> -npag
iii
Contents
Section
CHAPTER 1 OVERVIEW OF DOMAIN C COMPILER
1.1 New Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.2 Function Prototypes . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
1.2.1 Prototypes and System Calls . . . . . . . . . . . . . . . . . . . 1-4
1.3 COFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
1.4 Absolute Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
1.5 Accessing FORTRAN Common Blocks . . . . . . . . . . . . . . . . . . . . 1-6
1.6 Reference Variables . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
1.7 Informational Messages . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
1.8 Differences Between /bin/cc and /com/cc . . . . . . . . . . . . . . . . 1-8
1.8.1 Compilation and Linking Process . . . . . . . . . . . . . . . . . 1-8
1.8.2 Different Preprocessors . . . . . . . . . . . . . . . . . . . . . 1-8
1.8.3 Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
1.8.4 Command Line Switches . . . . . . . . . . . . . . . . . . . . . . 1-9
1.8.5 Optimization Levels. . . . . . . . . . . . . . . . . . . . . . . . 1-9
CHAPTER 2 INSTALLATION INFORMATION
CHAPTER 3 DOCUMENTATION
CHAPTER 4 BUGS AND BUG FIXES
Contents iv
CHAPTER 1
OVERVIEW OF DOMAIN C COMPILER
The Domain C compiler released with SR10 includes some major enhancements and
changes. These release notes list new features and describe how to update
programs from previous releases. For more information about new features,
consult the Domain__C__Language__Reference_ (order no. 002093). For more
information about updating old programs, refer to the Making__the__Transition
to_SR10_Operating_System_Releases document (order no. 011435).
1.1 New Features
The SR10 version of the Domain C compiler contains the following new
features:
o New_Object_Code_Format -- At SR10, all Domain compilers produce
object modules that are consistent with AT&T's Common Object
File Format (COFF). These object modules are not compatible with
object modules produced by previous releases. To make full use
of SR10 program development tools, you should recompile all source
files.
o Function_Prototypes -- Domain C supports function prototypes as
defined in the proposed ANSI standard and in the C++ language.
o Reference_Variables -- Domain C supports reference variables as
implemented in the C++ language.
o Absolute_Code -- Previously, Domain C produced position-independent
code (PIC). At SR10, the Domain C compiler produces absolute code by
default, which will make most programs run faster. You can still
produce position-independent code by specifying the -pic option on
the /com/cc command line.
o Generic_Pointers -- The Domain C compiler supports pointers to void,
as defined in the proposed ANSI standard.
1-1 SR10 Domain C Compiler
o Flexnames -- Identifiers are now unique up to the first 4096
characters.
o UNIX_Preprocessor___(cpp) -- Domain C now supports the UNIX
preprocessor (cpp) as well as the Aegis preprocessor. For the most
part, the two preprocessors are identical, but there are a few
differences of which you should be aware.
o Cross-Language_Support -- In addition to prototypes and reference
variables, which both facilitate cross-language support, Domain C
also supports a new #options specifier that enables you to identify
the register in which function return values are to be stored. In
addition, Domain C supports an __attribute[section] modifier that
enables you to create overlay sections. This is particularly useful
when you compile with the /bin/cc command.
o Informational_Messages -- In addition to warnings and errors, the
Domain C compiler now issues informational messages. These messages
identify sections of your source file that will produce inefficient
or non-portable code. You can suppress these messages with the new
-info switch, which is available with the /com/cc command.
o Profiling -- SR10 supports profiling of programs via the prof and
gprof utilities. To profile a program, you must compile with the -p
or -pg switches (in a a BSD environment), or with the -qg or -qp
switches (in a SysV environment). Note that these switches are
available only with /bin/cc. If you use the /com/cc command, you
must compile with the -profile switch.
o INLIB -- The Aegis inlib command is no longer supported at SR10. To
load a shared a library, you must specify the -inlib switch when you
compile with /com/cc or bind your program.
o Case_of__Global__Names -- Prior to SR10, the Domain C compiler
reversed the case of all global names when writing them to the object
file. At SR10, the Domain C compiler emits global names exactly as
they are written. This is consistent with the new versions of Domain
Pascal and FORTRAN, which now convert all global names to
lowercase.
o Cross-Compilation_for_Different_UNIX_Environments -- There is a new
-runtype switch (/com/cc only) that enables you to produce code
for one UNIX environment while compiling in a different environment.
o In-Line_Functions -- The Domain C compiler now supports in-line
routines for some of the standard library functions declared in
<strings.h> and <math.h>. The in-line code produces faster
executable code because it removes the overhead involved in passing
control to external functions. To use the in-line routines, include
the header file <builtins.h> at the top of your source file.
All of these features are described in detail in the new Domain_C_Language
SR10 Domain C Compiler 1-2
Reference. The following sections highlight those changes that can produce
unexpected results when you recompile existing programs.
1.2 Function Prototypes
At SR10, the Domain C compiler supports function prototypes, as defined in
the proposed ANSI C standard. Prototypes provide two main benefits:
o Prototypes enable the compiler to perform type-checking of function
parameters, which can result in early diagnosis of potential bugs.
o Prototypes turn off the automatic argument promotions (chars and
shorts to ints, and floats to doubles) that are normally performed.
Suppressing these conversions can result in significantly faster
code.
Because the compiler expects prototypes for all functions, you may receive
informational messages if your source file contains old-style declarations or
definitions. These messages will be displayed only if your info setting is 1
or greater. For example, suppose the source file, helloworld.c, contains
the following:
main()
{
printf("Hello World\n");
}
If you compile with the SR10 Domain C compiler and specify an informational
level greater than zero, you will receive the warnings shown below:
$ /com/cc hello_world.c -info 1
(0002) {
******** Line 2: [info #213] No prototype in scope, default prototype "main(...)"
assumed.
(0003) printf("Hello world\n");
******** Line 3: [info #213] No prototype in scope, default prototype "printf(...)"
assumed.
No errors, No warnings, 2 informational Messages, C Compiler, Rev 6.00
1-3 SR10 Domain C Compiler
The default prototypes -- main(...) and printf(...) -- have the same
semantics as no prototypes at all. That is, they indicate that the functions
take an unspecified number of arguments of unspecified type.
You can suppress the warnings by compiling with the -ntype switch or by
compiling with an info setting of zero (the default). However, a better way
to suppress the messages is to enter the appropriate prototypes:
int main( void )
{
extern int printf( char *, ... );
printf("Hello World\n");
}
Another way to specify the prototype of printf() is to include the <stdio.h>
header file:
#include <stdio.h>
All of the functions in the standard C library are prototyped in the header
files located in /usr/include.
1.2.1 Prototypes and System Calls
To take advantage of the type-checking provided by prototypes, there is a new
set of header files for system calls. These ".h" files are located in
/usr/include/apollo. The old insert files located in /sys/ins that use
std_$call will continue to be supported although they will become obsolete at
a future release. We strongly recommend that you use the new header files
for all new programs and that you convert existing programs as soon as
possible.
In addition to type-checking, the prototypes provide a much cleaner interface
to system routines. In particular, prototypes suppress automatic type
conversions so it is no longer necessary to cast char, short, and
float arguments. In addition, the system call prototypes make use of
another new feature--reference variables--which enable you to pass arguments
by reference. Reference variables are described later in this release
document.
SR10 Domain C Compiler 1-4
1.3 COFF
Object files produced by SR10 compilers are compatible with the Common Object
File Format specified by AT&T. As a result, these object files are not
compatible with object files produced by previous Domain compilers. When you
recompile, therefore, you should recompile all source modules in a
program. The /bin/ld link editor and the /com/bind binder cannot link COFF
modules with old-style object modules. It is possible for the loader to load
a combination of COFF modules and old-style modules, so you do not
necessarily need to recompile shared libraries. However, we recommend that
you convert all modules to COFF as soon as possible.
1.4 Absolute Code
At SR10, all Domain compilers produce absolute code by default. In most
cases, this change will be transparent, except that your programs should run
somewhat faster.
Note: If you compile for absolute code and you reference global data in
a shared library, that library must either be installed when compiling,
or else you must specify the library with the -inlib switch.
In addition, there are two cases where you must direct the compiler to
produce postion-independent code (PIC). These two cases are:
o Routines that will be placed a shared library
o Programs that are dynamically loaded, such as IOS type managers
Use the -pic switch to force the compiler to produce position-independent
code. For example:
$ /com/cc -pic lib_func
Note that all routines in a library must be compiled with the -pic switch.
Even if only one of the routines is composed of absolute code, the entire
library will be loaded as absolute code.
1-5 SR10 Domain C Compiler
1.5 Accessing FORTRAN Common Blocks
If you have programs that access FORTRAN common blocks, you should be aware
of the new __attribute[section] specifier that enables you to create an
overlay section. Note that this specifier is useful only for programs that
you compile with the /bin/cc command. If you compile with the /com/cc
command, the compiler will automatically create overlay sections for all
global variables, as in the past. Consult Chapter 7 of the Domain_C__Language
Reference for more information about accessing FORTRAN common blocks.
1.6 Reference Variables
At SR10, Domain C supports reference variables, as defined in the C++
language. The most significant impact of this new feature is that the new
prototypes for system calls use reference variables to distinguish between IN
parameters and other types of parameters. IN parameters are declared as
reference variables, enabling you to pass the arguments by reference. All
other parameter are declared as pointers. For instance, the prototype for
ios_$set_dir is:
extern void
ios_$set_dir(
char *pname,
pinteger&plen,
ios_$dir_type_t &dir,
status_$t *status
);
This means that plen and dir will be passed by reference, whereas pname and
status will be pointers passed by value. For example, the invocation might
be:
...
char pname[100];
pinteger plen;
ios_$dir_type_t dir;
status_$t status;
...
ios_$set_dir( pname, plen, dir, &status );
Note that only status requires an ampersand in front of it. pname is the
name of an array, so it is interpreted as a pointer to the beginning of the
array; plen and dir are declared as reference variables, so the compiler
SR10 Domain C Compiler 1-6
automatically passes their addresses.
1.7 Informational Messages
In addition to warnings and errors, the Domain C compiler now issues a third
class of messages called "informational messages". These messages alert you
to aspects of your program that could be coded more efficiently. By default,
these messages will not be displayed. To see them, you need to compile with
the -info switch set.
1.8 Differences Between /bin/cc and /com/cc
Since SR9.0, Domain systems have supported two commands for invoking the
Domain C compiler -- /com/cc and /bin/cc. These two commands have always had
slightly different functionality. For example, the two commands accept
different command line options, and #include directives are interpreted
differently depending on which command you use. At SR10, the /bin/cc command
includes additional UNIX functionality, which produces a few more differences
between it and /com/cc. In particular, you should be aware of the
differences listed in the following subsections.
It is important to understand that you can invoke /bin/cc or /com/cc
regardless of what operating system environment is running. If you are in an
Aegis shell, you can invoke /com/cc simply by entering the cc command. If a
UNIX environment is installed, you can invoke /bin/cc by entering the full
pathname.
If you are in a UNIX shell, you will get /bin/cc by default when you execute
the cc command. Executing /com/cc in a UNIX environment can be more
difficult, depending on whether Aegis is installed on your node. If Aegis is
installed, you can execute /com/cc simply by entering the full pathname. If
Aegis is not installed, you can execute the /com/cc command by using the -Y0
switch:
% cc -Y0 test.c
1-7 SR10 Domain C Compiler
1.8.1 Compilation and Linking Process
All C source filenames on a /bin/cc command line must end with a ".c"
extension, and the full filename must be specified. Files compiled by
/com/cc may have any extension. Moreover, if the filename ends in a ".c"
extension, the extension may be omitted on the command line.
The /com/cc command can compile only one source file at a time. The
/bin/cc accepts multiple source filenames on the command line. In addition,
you can specify object files, which are passed to the /bin/ld link editor.
All source modules compiled by /bin/cc must be processed by a linker
(/bin/ld or /com/bind) before being executed. In contrast, modules
compiled by /com/cc that do not contain unresolved global references may be
executed without being linked. Note that the /bin/cc command automatically
invokes the /bin/ld link editor after compiling.
By default, the /bin/cc command produces an executable file named a.out. If
it cannot produce an executable file (because there are unresolved global
symbols), the /bin/cc command creates an object file with a ".o" extension
for each source file specified on the command line. The /com/cc command
always creates just one file, an object file with a ".bin" extension. If
there are no unresolved gloabl references, this object file will be
executable.
1.8.2 Different Preprocessors
The /bin/cc command invokes the UNIX C preprocessor before invoking the
Domain compiler. This means that you execute /bin/cc with cpp command
options. In addition, the two preprocessors evaluate include pathnames
somewhat differently.
If you use /bin/cc, relative pathnames in #include directives are
evaluated with respect the source file's directory. If you use /com/cc,
pathnames are evaluated with respect to the working directory. This
difference has always existed and is well documented in the Domain__C
Language_Reference -- we mention it here for completeness.
1.8.3 Global Variables
Unlike /com/cc, /bin/cc does not create a named overlay section for every
global variable. If you need to create an overlay section (e.g., to access a
FORTRAN common block) you must use the new __attribute[section] specifier.
SR10 Domain C Compiler 1-8
1.8.4 Command Line Switches
The /bin/cc and /com/cc commands accept completely different sets of command
switches. See the Domain__C__Language_Reference for complete details about
these options. Keep in mind, however, that the /bin/cc options must be case
correct whereas that /com/cc options may be written in upper- or lower-case.
Also note that some /bin/cc options are specific to BSD4.3 or SysV.3.
1.8.5 Optimization Levels
By default, /com/cc compiles at optimization level 3, whereas /bin/cc
compiles at optimization level 0.
1-9 SR10 Domain C Compiler
CHAPTER 2
INSTALLATION INFORMATION
You can install the C Compiler Version 6.00 on a user node (one equipped with
monitor and keyboard) or a Domain Server Processor (DSP) that is running
SR10 or a more recent version of the Domain/OS operating system.
For directions about how to install this product, see the manual Installing
Software__with__Apollo's__Release__and___Installation___Tools, (Order No.
008860-A00).
If the user node or DSP is not running SR10 or a more recent version of the
Domain/OS operating system, follow the appropriate optional software update
procedures as described in Chapter 5 of Installing_Domain_Software (Order
No. 008860 Rev 02).
NOTE: The user node or DSP must have a minimum of 2488 blocks of
available disk space for a successful installation of this
software.
2-1 SR10 Domain C Compiler
CHAPTER 3
DOCUMENTATION
There is a new version of the Domain_C_Language__Reference (order no.
002093-A00) that describes all new features of Domain C.
3.1 -es|-esf and -E|-P Preprocessor Options
The /com/cc es|-esf options and the /bin/cc-E|-P preprocessor options both
produce an expanded source file from the original source code.
The difference is that the -es and -E options add line directives to the
expanded source file, while the -esf and -P options explicitly delete the
line directives.
3.2 Level 3 and 4 Informational Messages
The -info option provides four levels of informational messages for the
Series 10000 workstations.
Level 3 messages indicate if a pointer is being assigned the address of an
object that is not naturally aligned.
Level 4 messages provide the same information, but the warning is not
suppressed for pointers whose object alignment is specifically declared.
Level 3 and 4 messages are described in Appendix C in the Making_the
Transition_to_SR10 document.
3-1 SR10 Domain C Compiler
3.3 attribute Modifier Is Obsolete
The #attribute modifier is obsolete and has been replaced with __attribute.
Although #attribute will continue to work correctly, it should be replaced
with __attribute. The attribute specifiers continue to work in the same way
as before.
3.4 The aligned Specifier for the __attribute Storage Class Modifier
The Series 10000 workstations support a new aligned specifier for the
__attribute storage class modifier. The __attribute[aligned] modifier causes
the compiler to align the object to which it is applied on the boundary you
specify. The __attribute[aligned] modifier is described in Appendix C in the
Making_the_Transition_to_SR10 document.
3.5 __STDC__
The help file for the Domain C compiler should read "Also defines __STDC__ to
be 1"; __STDC__ should be capitalized.
SR10 Domain C Compiler 3-2
CHAPTER 4
BUGS AND BUG FIXES
This chapter describes known bugs and bugs fixed since SR9.7.
The following bug has not yet been fixed:
If you call a function through a pointer to a function with a prototype,
the constant arguments will not be coerced to the correct size.
The APRs (Apollo Product Reports) with the following numbers have been fixed:
000DBF4B
C compiler error on void function nodes.
000DBF55
Incorrect code for constant parameter.
000DBF53
Incorrect results for 8 queens benchmark.
000DBF4E
Initialized data in .bss not correct.
000DBF4F
Bad unsigned comparison.
000DBF51
Compiler getting confused on file names.
4-1 SR10 Domain C Compiler