compile command (UNIX)
Invoke the C compiler:
cc [options] [operands] c89 [options] [operands]Invoke the C++ compiler:
CC [options] [operands]
The beta libraries are searched before the standard libraries. The beta libraries include updates made since the last formal release of the software and can be updated by modem using the QNX update system.
The {w|d|c} part of this option specifies the type of debugging output:
Option | Model | 16-bit | 32-bit |
---|---|---|---|
ms | small | 64K code, 64K data | 4G code, 4G data |
mc | compact | 64K code, >64K data | N/A |
mm | medium | >64K code, 64K data | N/A |
ml | large | >64K code, >64K data | N/A |
mh | huge | >64K code, >64K data with objects >64K | N/A |
mf | flat | N/A | 4G code, 4G data |
The small memory model is selected by default. For 16-bit applications, libraries are provided for the small, compact, medium, large, and huge memory models.
For 32-bit applications, only small-model libraries are provided and only small-model compiling is supported. However, cc does permit 32-bit small-model object modules to be linked as either small or flat models (flat-model linking is the default).
Model | Stacksize |
---|---|
32-bit flat | 32k |
32-bit small | 8k |
16-bit | 4k |
extern int i; void rtn( int *pi ) { int k; for( k = 0; k < 10; ++k ) { (*pi)++; i++; } }In this example, if i and *pi referenced the same integer object, i would be incremented by 2 each time through the for loop. The pointer reference *pi would be an alias for the variable i. As a result, in binding the variable i to a register, the compiler would have to make sure the ``in-memory'' copy of i was kept up-to-date. It's unlikely this situation would arise, since you probably wouldn't reference the same variable directly by name and indirectly by a pointer. The -Oa option instructs the code generator that such cases don't arise in the module to be compiled. When the generator doesn't have to worry about the alias problem it can produce more efficient code.
cc -g -Os reportthe default -Od is overridden.
Example:
cc -Oe dhrystone cc -Oe=25 whetstone
16-bit compiler | 32-bit compiler |
---|---|
push BP | push EBP |
mov BP, SP | mov EBP, ESP |
16-bit compiler | 32-bit compiler |
---|---|
inc BP | inc EBP |
push BP | push EBP |
mov BP,SP | mov EBP,ESP |
The f+ flag generates prologue sequences in the same way as the f flag.
abs()
_disable()
div()
_enable()
fabs()
_fmemchr()
_fmemcmp()
_fmemcpy()
_fmemset()
_fstrcat()
_fstrcmp()
_fstrcpy()
_fstrlen()
labs()
ldiv() (32)
lrotl() (32)
lrotr() (32)
inp()
inpw()
memchr()
memcmp()
memcpy()
memset()
movedata()
outp()
outpw()
_rotl()
_rotr()
strcat()
strchr()
strcmp()(16)
strcpy()
strlen()
A (16) indicates that the function is generated inline by the 16-bit compiler only; a (32) indicates that it's generated inline by the 32-bit compiler only.
If you specify -Oi, the macro __INLINE_FUNCTIONS__ is predefined by the compiler.
If you also specify Ot, the exp() function is generated as well.
version_string <tab>bins=directory_path <tab>hdrs=directory_path <tab>libs=directory_path [ccopts=cc_options] ...
where the version_string is the version name cc is to recognise, and a directory_path is search path delimited by colons (:), such as ``directory1:directory2''. The ccopts= cc_options is optional. It may be used to specify additional command line parameters to cc that are to be used for that version of the compiler. A typical entry might look like:
10.6 bins=/usr/watcom/10.6/bin hdrs=/usr/watcom/10.6/usr/include:/usr/include libs=/usr/watcom/10.6/usr/lib:/usr/lib
For this processor: | specify: |
---|---|
assembler | s |
C compiler | c |
C++ compiler | C |
disassembler | d (used in conjunction with -S) |
linker | l |
preprocessor | p (used in conjunction with -E or -P) |
SQL preprocessor | S |
If option contains a space, you must enclose the entire option in double quotes (for example, "-Wc,-xfile1").
The command specified by option is defined by the language processor being used. Please refer to the appropriate documentation.
Compile test.c and create a 32-bit executable program in the current directory with the name a.out:
cc test.c
Compile test.c and create a 32-bit executable program in the current directory with the name test:
cc -o test test.c
Compile test.c and create an executable program in the current directory with the name test. Use the default rules to invoke cc (see the make utility in the QNX Utilities Reference):
make test
Compile test.c and create a 16-bit object file in the current directory with the name test.o:
cc -2 -c test.c
Disable stack overflow checking by passing the -s option to the C compiler:
cc -Wc,-s test.c
For more information on specific compiler options, see the C/C++ Compiler Options chapter of the Compiler & Tools User's Guide. |
The cc utility is the QNX compiler interface. It's based on the POSIX c89 utility.
The cc utility takes a list of source and object modules on the command line and invokes the appropriate parser to compile each file. Object modules are passed straight through to the linker. The file suffix determines which parser is used, as follows:
Suffix | Parser |
---|---|
.S,.asm | Assembler |
.c | C compiler |
.C, .cc, .cpp | C++ compiler |
.sqc | Embedded SQL preprocessor |
The parser must exist for you to use it. The cc utility was designed to work with potential future parsers and may contain entries for parsers not yet available. |
The cc utility doesn't allow multiple options to be specified after a dash character (-). For example, -bc isn't valid; you must specify -b -c instead. Operands (source and object files) and options may be mixed and specified in any order. Some options like -I and -L are order-dependent - the order in which they appear in the command line determines the order of the searches made. All command-line arguments are processed before any compilation or linking begins.
When cc encounters a compilation error that stops an object file from being created, it writes a diagnostic to the standard error and continues to compile other source files, but it bypasses the link phase and returns a nonzero exit status. If any file generates warnings or errors, and standard error is a tty (that is, it isn't a pipe), a new file is created with the same name as the input file but with a .err suffix. If the link phase is entered and is unsuccessful, a diagnostic is written and cc exits with a nonzero status.
The -c option suppresses the link phase. If you have many separate source files that you must update and modify individually, you'll probably use the -c option frequently.
In QNX, a program can run at one of the privity levels in the following table. The -T option lets you set the privity.
Privity | Description |
---|---|
0 | Privity is determined at load time. |
1 | Required for programs using cli, sti, in, out opcodes. Most programs with interrupt handlers fall into this category. |
2 | Reserved. |
3 | Used by the vast majority of programs. |
With level 0, the privity of the program is automatically set when the program is loaded. If the program is invoked by the superuser, its privity is set to 1; if the program is invoked by a normal user, its privity is set to 3. You should find this feature useful if your program needs to do in/out opcodes only when it is run by a superuser.
If a program is set to privity level 1, any attempt to execute that program by a non-superuser results in denied access.
Although you must be a superuser to execute privity level 1 programs, privity and superuser are two different concepts. The concept of superuser comes from POSIX, while privity relates only to Intel 286, 386, 486, and Pentium processors and allows or disallows a small set of opcodes.
If you link a program under QNX 4.1 (or later), its privity defaults to 3. If you find this program terminates with a SIGSEGV, check to see if it faults on one of the special opcodes that require privity level 1. If so, you should relink using the -T 1 option.
You may occasionally wish to examine the assembly code produced by the code generator. The -S option produces an assembly file ending in .S. You can also take an object file and convert it back to assembly with this option.
If you need to specify a parameter to any of the language processors, you may use the -W c,option. Check the documentation on each processor to determine its options.
The table below describes how the options for the cc command correspond to those for the Watcom C/C++ compiler and linker:
cc option | Compiler option | Linker option |
---|---|---|
0 | 0 | |
2 | 2 | |
3 | 3 | |
3[r,s] | 3[r,s] | |
4 | 4 | |
4[r,s] | 4[r,s] | |
5 | 5 | |
5[r,s] | 5[r,s] | |
b | LIBRARY beta libraries | |
B | LIBRARY backward compatibility libraries | |
D name=text | d+, dname[=text] | |
E | p | |
F | fo | |
f{option} | f{option} | |
g{1|2|3}{w|d|c} | d{1|2|3}, h{w|d|c} | DEBUG ALL |
g1{+} | d1{+} | DEBUG ALL |
I directory | i=directory | |
j | j | |
l library | LIBRARY library | |
L directory | LIBPATH directory | |
m{f|s|c|m|l|h} | m{f|s|c|m|l|h} | |
M | OPTION MAP | |
N stacksize | OPTION STACK=stacksize | |
o outfile | NAME outfile | |
O{a,d,i,l,s,t,x} | o{a,d,i,l,s,t,x} | |
P | p fo=name.i | |
Q | zq | QUIET |
T level | OPTION PRIVILEGE=level | |
U name | uname | |
Wc,option | option | |
w warning_level | wwarning_level | |
z{option} | z{option} |
The default output file is named a.out. This default may be changed with the -o option.
Note that the make utility, when used with the default settings,
produces an output file with the same name as the input file. For example:
make file1 results in the executable output file file1. |
lex utility (Lexical analyzer generator), make utility (Maintain, update and regenerate groups of programs), yacc utility (Parser generator), Watcom Compiler & Tools User's Guide