Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
1
פ
15
Preprocessor
"
ע מ
נ
מ ע מ
מ ע
נ ע מ
עמ מ מ
,
מ
נמ
-
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
2
-0
0000
0
1
0001
1
2
0010
2
3
0011
3
4
0100
4
5
0101
5
6
0110
6
7
0111
-
פ
•
'
'
(
)
•
:
.1
.2
.3
(compiler)
+
.
.4
.
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
-
C
:
C Data Type Compaq Alpha Typical 32-bit Intel IA32
int
4
4
4
long int
8
4
4
char
1
1
1
short
2
2
2
float
4
4
4
double
8
8
8
long double
8
8
10/12
char *
8
4
4
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
-
פ
(
)
George Bool
-
19
'
'
ס
1
'
'
-0
And
& 0 1
0 0 0
1 0 1
!
0 1
1 0
Not
Or
| 0 1
0 0 1
1 1 1
^ 0 1
0 0 1
1 1 0
Exclusive-Or (Xor)
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
-
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
6
0
1
(byte)
C
.
!!!
(char, short, int, long)
-unsigned
-
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
7
2
(
)
(
8
)
"
0
.
042
34
-
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
8
(
16
)
"
0x
.
0x42
66
.
%x
(
X
%
)
-
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
9
:
"
"
2
(
0
)
"
,
0
1
2
3
4
5
6
7
8
1
2
4
8
16
32
64
128
256
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
-
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
10
,
:
00001101
:
1
=
1
,
0
=
2
,
1
=
4
,
1
=
8
,
0
=
16
,
0
=
32
,
0
=
64
,
0
=
128
"
13
:
1*1+0*2+1*4+1*8+0*16+0*32+0*64+0*128 =
1*1 + 1*4 + 1*8 =
-
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
11
:
0
-2
,
,
.
,
0
-
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
12
ס
8
:
00001000
0
8
0
4
0
2
1
1
-
פ
Shayke Bilu PhD
-
פ
Shayke Bilu PhD
-
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
Shayke Bilu PhD
16
ס
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
17
-
#include
-
#define
#undef
macro
ס
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
-
Pre-Compiler
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
19
(
Pre-Compiler
/
(Pre-Processor
(
)
-
#include
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
20
#include
-#include
,
.
2
:
.1
#include
<filename
>
-
.2
#include
ףfilenameפ
-
(
)
"
.
#include
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
21
#include
<stdio.h>
#include
ף
DefinitionFile.h
פ
#include
ףc:
\\HeaderFiles\\DefinitionFile.h
פ
פ
(
)
-
#define
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
22
#define
#define
identifier alternative-text
identifier
-alternative-text
identifier
ס
(
.)
פ
(
)
-
#define
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
23
alternative-text
ס
(
\
)
identifier
identifier
identifier
(
"
"
-
#define
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
24
#define
OK 1
printf(
ףOKפ
); \\
int
NOT_OK; \\
\\
int
status = OK;
#define
INFINITE
for
(;;)
?
INFINITE printf(
ףHelloפ
);
#define
DOUBLE + NUM + NUM
#define
QUADROUPLE DOUBLE DOUBLE
int
NUM=5;
if
(DOUBLE DOUBLE== 20)
פ
-
#define
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
25
,
#define
identifier(argument-list) alternative-text
)
identifier
argument-list
alternative-text
#define
max(A,B) ((A)>(B)? (A) : (B))
פ
-
#define
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
26
inline
-"
A
-B
"
max(i++, j++);
-
#undef
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
27
"
-
define
:
SCE-Chapter-15-Preprocessor
Shayke Bilu PhD
28
-
Conditional Inclusion
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
29
-"
-
conditional-statements
(
)
/
#if
integer
.
-0
,
#elif/#else/#endif
C
-casting
,
sizeof
ס
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
30
#if
integer-expr1
#elif
integer-expr2
#else
#endif
#include
,
-
#defined
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
31
defined(name)
1
name
"
#define
-0
header
#if
!defined(INC_FILE)
#define
INC_FILE
//
// header file content
-
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
32
#if
-#defined
(debugging)
:
#if
defined(DEBUG)
printf(
ףVariable x has value = %dפ
, x);
-
"
#ifdef
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
33
#define
,
:
#ifndef
INC_FILE
#define
INC_FILE
// header file content
פ
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
34
LINE
-
FILE
-
DATE
TIME
פ
פ
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
35
#line
number
ס
-number
.
"
"
#error
error-text
ס
assert(condition)
(
-"
(
ף
assert.h
,
,
SCE-Chapter-15-Preprocessor
Shayke Bilu PhD
36
SCE-Chapter-15-Preprocessor
Shayke Bilu PhD
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
38
.1
.
.2
MINIMUM2
2
.
.
.3
MINIMUM3
3
.
.
.4
PRINTARRAY
.
.
.5
DIVBYTEN
-
10
1
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
39
.6
ISOCTAL
8
,
1
0
.
.7
ISDECIMAL
10
,
1
0
.
.8
ISHEXADECIMAL
16
,
1
0
.
.9
SWAP
.
.10
DETAILS
ס
Shayke Bilu PhD
SCE-Chapter-15-Preprocessor
40
:C
-
#include
-
#define
#undef
macro
if
#
-
ס
SCE-Chapter-15-Preprocessor
Shayke Bilu PhD
41