Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet206/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   202   203   204   205   206   207   208   209   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

Directive
Meaning
Example
#define
Macro substitution definition to replace a 
given string with another string
#define MAX 1000
#define getmax(a,b) 
((a 
>
b)?(a):(b))
#include
Include header file into this file before 
compilation
#include 
<
stdio.h 
>
#include “myheader.h”
#ifdef… #endif
If parameter has been defined, perform 
the following task
#ifdef MAX
int a[MAX];
#endif
#ifndef…#endif
If parameter is not defined, perform the 
following task
#ifndef MAX
#define MAX 1000
#endif
#if…#else…#endif
Test given parameter, perform associated 
action (#elif clauses are also permitted)
#if MAX 
>
500
int a[500];
#else
int a[MAX];
#endif


Software Installation and Maintenance

555
sense? For instance, if z is an array, you cannot apply 
++
to it whereas if x is an int, you 
cannot add 1.5 to it.
As with the previous two phases, semantic errors can be caught during this phase. 
While lexical and syntactic errors are misuses of the programming language itself, seman-
tic errors are misapplications of the programming language.
If the semantic analysis completes without error, the code can be converted. Typically, 
as an intermediate stage, the code is first converted to assembly language; thus we have an 
assembly component. Next, the assembly code is converted by assembler to machine lan-
guage code (executable code). Even here, gcc is not finished. Optionally, you can ask that 
gcc optimize the code. This is particularly useful for today’s processors that offer a number 
of parallel processing hardware elements that can execute program code more effectively 
if that code is compiled specifically to match the architecture. Optimization itself may 
require several additional passes through the code. The result is an executable program (or 
multiple executable programs).
13.6.4 Linking
Earlier in this chapter, we examined the role of the library file and the need to track down 
dependencies. The C/C
++
programming languages use library files extensively. This allows 
you to utilize pieces of precompiled code without having to write your own versions. 
Libraries in both C and C
++
are extensive and include such necessary functions as input 
and output operations and string and character operations but also include random num-
ber generation, dynamic memory allocation functions, math functions, type conversion 
operations, and diagnostic and testing functions to name just a few.
If (x > y–z) {
x = x+15;
[If-op] [Condition]
[If-clause]
[Block]
x > y–z

y
z

<
[Assign]
[Id] [Relational-op] [Expr]
[Id] [arith-op] [id]
[Id] [assign-op] [expr];
x = [Id] [arith-op] [literal] 
[Id] [incr-op];
z++
x
+ 1.5
[Assign] }
{
z++;
)
(
}
FIGURE 13.9 
Parse tree for C instruction.


556

Linux with Operating System Concepts
In order to utilize a function written in an external file, you must include the function’s 
prototype. This is a definition of the function, similar to a function header. For instance, 
the function prototype for the printf output function is
int printf(const char *format, . . .);
meaning that this function will return an int value and expects to receive at least one 
parameter, a char pointer (string). The … indicates that optional parameters may also be 
passed to the function.
In order to simplify the use of library functions, header files collect together information 
that the compiler will need in order to use those functions. These will include at a minimum 
the function prototypes but may also include constants and data types defined for use in 
those functions as well as global variables. These are collectively placed into a text file known 
as a header file, labeled with a .h extension. You include header files by using 
#include 
<

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   202   203   204   205   206   207   208   209   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish