⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 express.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
📖 第 1 页 / 共 3 页
字号:
.ix 'operator' '++'
.ix 'operator' 'pre-decrement'
.ix 'operator' '--'
.uillust begin
pre-increment-expression:
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:MONO.++:eMONO. unary-expression

pre-decrement-expression:
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:MONO.--:eMONO. unary-expression
.uillust end
.* .keep end
.pp
The operand of the pre-increment and pre-decrement operators must be
a modifiable lvalue, and a scalar (not a structure, union or array).
.pp
The operand is incremented or decremented by 1, adjusted for the
type of the operand.
For example, if the operand is declared to be
a "pointer to
.us type
..ct ", then the increment or decrement will be by the value
.monoon
sizeof(&SYSRB.:HP1.type:eHP1.&SYSRB.)
..ct ..li .
.monooff
.pp
The expression
.mono ++obj
is equivalent to
.mono (obj&SYSRB.+=&SYSRB.1)
..ct ,
while
..se hyphenmode=&syshy
..hy off
.mono --obj
..hy &hyphenmode
is equivalent to
.mono (obj&SYSRB.-=&SYSRB.1).
.*
.section Address-of and Indirection Operators
.*
.uillust begin
unary-expression:
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:MONO.&:eMONO. cast-expression
.uor
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:MONO.*:eMONO. cast-expression
.uillust end
.pp
The unary
.mono &
symbol denotes the
.ix 'operator' 'address-of'
.ix 'operator' 'unary &'
.ix 'operator' '&'
.ix 'unary operator' '&'
.ix 'address-of operator'
.us address-of
operator.
Its operand must designate a
function or an array, or be an lvalue that designates an
object that is not a bit-field and is not declared with the
.kw register
storage-class specifier.
If the type of the operand is "
..ct .us type
..ct ",
then the type of the result is "pointer to
.us type
..ct " and the result is the address of the operand.
.pp
If the type of the operand is "array of
.us type
..ct ", then the type of the result is "pointer to
.us type
..ct " and the result is the address of the first element of the array.
.pp
The
.mono *
symbol, in its unary form, denotes the
.ix 'operator' 'indirection'
.ix 'operator' 'unary *'
.ix 'operator' '*'
.ix 'unary operator' '*'
.ix 'indirection operator'
.us indirection
or
.ix 'operator' 'pointer'
.ix 'pointer operator'
.us pointer
operator. Its operand must be a pointer type, except that it may not
be a pointer to
.kw void
..ct ..li .
If the operand is a "pointer to
.us type
..ct ", then the type of the result is "
..ct .us type
..ct ",
and the result is the object to which the operand points.
.pp
No checking is performed to ensure that the value of the pointer is
valid. If an invalid pointer value is used, the behavior of
.mono *
is
undefined.
.keep begin
..sk 1 c
Examples:
.millust begin
int   counter;
int * ctrptr;
void  (*fnptr)( int, int * );

ctrptr  = &counter;
*ctrptr = 3;

fnptr = FnRetVoid;
fnptr( *ctrptr, &counter );
.millust end
.keep end
.*
.section Unary Arithmetic Operators
.*
.uillust begin
unary-expression:
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:MONO.+:eMONO. cast-expression
.uor
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:MONO.-:eMONO. cast-expression
.uor
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:MONO.~~:eMONO. cast-expression
.uor
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:MONO.!:eMONO. cast-expression
.uillust end
.pp
The
.mono +
symbol, in its unary form,
.ix 'plus' 'unary'
.ix 'unary operator' '+'
.ix 'unary operator' 'plus'
.ix 'operator' 'plus'
.ix 'plus operator'
simply returns the value of its operand.
The type of its operand must be an arithmetic type
(character, integer or floating-point).
Integral promotion is performed on the operand, and the result
has the promoted type.
.pp
The
.mono -
symbol, in its unary form, is the
.us negation
or
.ix 'unary operator' '-'
.ix 'unary operator' 'minus'
.ix 'unary operator' 'negative'
.ix 'negative' 'unary'
.ix 'minus' 'unary'
.ix 'operator' 'negative'
.ix 'operator' 'unary minus'
.us negative
operator.
The type of its operand must be an arithmetic type
(character, integer or floating-point). The result is the
negative of the operand. Integral promotion is performed on
the operand, and the result has the promoted type.
The expression
.mono -obj
is equivalent to
.mono (0-obj).
.pp
The
.mono ~~
symbol is the
.ix 'tilde'
.ix 'bitwise complement'
.ix 'ones complement'
.ix 'bitwise NOT'
.ix 'complement operator'
.ix 'NOT operator' 'bitwise'
.ix 'operator' '~~'
.ix 'operator' 'complement'
.ix 'operator' 'bitwise complement'
.ix 'operator' "1's complement"
.ix 'operator' 'not'
.ix 'operator' 'bitwise NOT'
.us bitwise complement, 1's complement
or
.us bitwise not
operator.
The type of the operand must be an integral type, and integral
promotion is performed on the operand. The type of the result is the
type of the promoted operand.
Each bit of the result is the complement of the corresponding bit in
the operand, effectively turning 0 bits to 1, and 1 bits to 0.
.*
.************************************************************************
.*
.* ..if '&target' eq 'PC' or '&target' eq 'PC 370' ..th ..do begin
.* .shade begin
.* With &wc286.,
.* if
.* .mono obj
.* is declared to be
.* .kw unsigned long
.* ..ct ,
.* then
.* .mono ~~obj
.* is equivalent to
.* .mono (4294967295U-obj)
.* ..ct ..li .
.* If
.* .mono obj
.* is declared to be any other unsigned type,
.* then
.* .mono ~~obj
.* is equivalent to
.* .mono (65535U-obj)
.* ..ct ..li .
.* .pp
.* With &wc386.,
.* if
.* .mono obj
.* is declared to be
.* .kw unsigned int
.* or
.* .kw unsigned long
.* ..ct , then
.* .mono ~~obj
.* is equivalent to
.* .mono (4294967295U-obj)
.* ..ct ..li .
.* If
.* .mono obj
.* is declared to be any other unsigned type,
.* then
.* .mono ~~obj
.* is equivalent to
.* .mono (65535U-obj)
.* ..ct ..li .
.* .shade end
.* ..do end
.* ..if '&target' eq 'PC 370' ..th ..do begin
.* .shade begin
.* With &wlooc.,
.* .mono ~~obj
.* is equivalent to
.* .mono (4294967295U-obj)
.* ..ct ..li .
.* .shade end
.* ..do end
.*
.************************************************************************
.*
.pp
The
.mono !
symbol is the
.ix 'logical NOT'
.ix 'NOT operator' 'logical'
.ix 'operator' '!'
.ix 'operator' 'logical NOT'
.us logical not
operator.
Its operand must be a scalar type (not a structure, union or array).
The result type is
.kw int
..ct ..li .
If the operand has the value zero, then the result value is 1.
If the operand has some other value, then the result is 0.
.*
.* .keep begin
.section The sizeof Operator
.*
.cillust begin
sizeof-expression:
.cbr
.monoon
&SYSRB.&SYSRB.&SYSRB.&SYSRB.sizeof
.monooff
unary-expression
.cor
.monoon
&SYSRB.&SYSRB.&SYSRB.&SYSRB.sizeof(
.monooff
type-name
.mono )
.cillust end
.* .keep end
.pp
The
.ix 'sizeof operator'
.ix 'operator' 'sizeof'
.kw sizeof
operator gives the size (in bytes) of its operand.
The operand may be an expression,
or a type in parentheses.
In either case, the type must not be a function, bit-field
or incomplete type (such as
.kw void
..ct ,
or an array that has not had
its length declared).
.pp
Note that an expression operand to
.kw sizeof
is not evaluated. The expression is examined to determine the result
type, from which the size is determined.
.pp
If the operand has a character type, then the result is 1.
.pp
If the type is a structure or union, then the result is the total
number of bytes in the structure or union, including any internal or
trailing padding included by the compiler for alignment purposes.
The size of a structure can be greater than the sum of the
sizes of its members.
.pp
If the type is an array, then the result is the total number of bytes
in the array, unless the operand is a parameter in the function
definition enclosing the current block,
in which case the result is the size of a pointer.
.pp
The type of the result of the
.kw sizeof
operator is implementation-defined,
but it is an unsigned integer type, and is represented by
.ix size_t
.kw size_t
in the
.hdr <stddef.h>
header.
.*
.************************************************************************
.*
..if '&target' eq 'PC' or '&target' eq 'PC 370' ..th ..do begin
.shade begin
For the &wcboth. compilers, the macro
.ix size_t
.kw size_t
is
.kw unsigned int
..ct ..li .
.shade end
..do end
..if '&target' eq 'PC 370' ..th ..do begin
.shade begin
For the &wlooc. compiler, the macro
.ix size_t
.kw size_t
is
.kw unsigned int
..ct ..li .
.shade end
..do end
.*
.************************************************************************
.*
.keep begin
..sk 1 c
Example:
.millust begin
struct s {
    struct s * next;
    int        obj1;
    int        obj2;
};
.millust end
.keep break
.millust begin
static struct s * SAllocAndFill( const struct s * def_s )
/*******************************************************/
{
    struct s * sptr;

    sptr = malloc( sizeof( struct s ) );
    if( sptr != NULL ) {
        memcpy( sptr, def_s, sizeof( struct s ) );
    }
    return( sptr );
}
.millust end
.keep end
.pc
The function
.mono SAllocAndFill
receives a pointer to a
.mono struct&SYSRB.s.
It allocates such a structure, and copies
the contents of the structure pointed to by
.mono def_s
into the allocated memory. A pointer to the allocated structure is
returned.
.pp
The library function
.libfn malloc
takes the number of bytes to allocate as a parameter and
.monoon
sizeof(&SYSRB.struct&SYSRB.s&SYSRB.)
.monooff
provides that value. The library function
.libfn memcpy
also takes, as the third parameter, the number of bytes to copy
and again
.monoon
sizeof(&SYSRB.struct&SYSRB.s&SYSRB.)
.monooff
provides that value.
.endlevel
.*
.* .keep begin
.section Cast Operator
.*
.uillust begin
cast-expression:
&SYSRB.&SYSRB.&SYSRB.&SYSRB.unary-expression
.uor
&SYSRB.&SYSRB.&SYSRB.&SYSRB.:HP0.(:eHP0. type-name :HP0.):eHP0. cast-expression
.uillust end
.* .keep end
.pp
When an expression is preceded by a type name
in parentheses, the value of the expression is converted to the
named type. This is called a
.ix 'cast operator'
.ix 'operator' 'cast'
.ix 'converting types explicitly'
.us cast.
Both the type name and the operand type must be scalar (not a
structure, union or array), unless the type name is
.kw void
..ct ..li .
If the type name is
.kw void
..ct ,
the operand type must be a complete type
(not an array of unknown size, or a structure or union that has
not yet been defined).
.pp
A cast does not yield an lvalue.
.pp
Pointers may be freely converted from "pointer to
.ix 'pointer' 'to void'
.ix 'void' 'pointer to'
.kw void
..ct " to any other pointer type without
using an explicit cast operator.
Pointers also may be converted
from any pointer type to "pointer to
.kw void
..ct ".
.pp
A pointer may be converted to a pointer to another type.
However,
the pointer may be invalid
if the resulting pointer is not properly
.ix alignment
aligned for
the type.
Converting a pointer to a pointer to a type with less strict
alignment, and back again, will yield the same pointer.
However, converting it to a pointer to a type with more strict
alignment, and back again, may yield a different pointer.
On many computers, where alignment is not required (but may improve
performance), conversion of pointers may take place freely.
.*
.**********************************************************************
.*
.shade begin
With
..if '&target' eq 'PC' ..th ..do begin
&wcboth.,
..do end
..el ..if '&target' eq 'PC 370' ..th .do begin
&wcall.,
..do end
..el ..if '&target' eq '370' ..th ..do begin
&wlooc.,
..do end
alignment of integers, pointers
and floating-point numbers is not
required, so the compiler does not do any alignment.
However,
aligning these types may make a program run slightly faster.
..if '&target' eq 'PC 370' ..th ..do begin
.pp
With both compilers, a
..do end
..el ..if '&target' eq 'PC' ..th ..do begin
.pp
A
..do end
command line switch may be used to force the compiler
to do alignment on all structures.
.shade end
.*
.**********************************************************************
.*
.pp
A pointer to a function may be converted to a pointer to a different
type of function, and back again. The resulting pointer will be the
same as the original pointer.
.pp
If a pointer is converted to a pointer
to a different type of function, and a call is made using that
pointer, the behavior is undefined.
.* (If the number and types of parameters and
.* the type of the return value are all identical, then there shouldn't
.* be a problem.)
.pp
A pointer may be converted to an integral type. The type of integer
required to hold the value of the pointer is implementation-defined.
If the integer is not large enough to fully contain the value, then
the behavior is undefined.
.pp
An integer may be converted to a pointer. The result is
implementation-defined.
.*
.************************************************************************
.*
..if '&target' eq 'PC' or '&target' eq 'PC 370' ..th ..do begin
.shade begin
With &wc286.,
for the purposes of conversion between pointers and integers,
.kwix &kwnear_sp.
.kwfont &kwnear.
pointers are treated as
.kw unsigned int
..ct ..li .
.kwix &kwfar_sp.
.kwfont &kwfar.
and
.kwix &kwhuge_sp.
.kwfont &kwhuge.
pointers are treated as
.kw unsigned long int
..ct ,
with the pointer's segment value in the high-order
(most significant)
two bytes.
All the usual integer conversion rules then apply.
Note that
huge
pointers
are not normalized in any way.
.shade end
.shade begin
With &wc386.,
for the purposes of conversion between pointers and integers,
.kwix &kwnear_sp.
.kwfont &kwnear.
pointers are treated as
.kw unsigned int
..ct ..li .
.kwix &kwfar16_sp.
.kwfont &kwfar16.
and
.kwix &kwisg16_sp.
.kwfont &kwiseg16.
pointers are also treated as
.kw unsigned int
..ct ,
with the pointer's segment value in the high-order
(most significant)
two bytes.
All the usual integer conversion rules then apply.
Note that
.kwix &kwfar_sp.
.kwfont &kwfar.
pointers may not be converted to an integer without losing
the segment information.
.shade end
..do end
..if '&target' eq 'PC 370' ..th ..do begin
.shade begin
With &wlooc.,
for the purposes of conversion between pointers and integers,
pointers are treated as

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -