Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INTRODUCTION
Structure of C Program Every C program consists of one or more modules called functions. One of the functions must be called main. The program will always begin by executing the main function, which may access other functions. Any other function definitions must be defined separately, either ahead of or after main
INTRODUCTION
Structure of a C Function A function heading, which consists of the function name, followed by an optional list of arguments (variables /parametres), enclosed in parentheses. A list of argument declarations, if arguments are not included in the heading. A compound of statements
BASIC C PROGRAM
BASIC C PROGRAM
BASIC C PROGRAM
BASIC C PROGRAM
BASIC C PROGRAM
assignment statement
PROGRAM EXECUTION In general program execution takes two steps Compile the source code.
Compilation is the process of converting the source code into machine language the very minimalist language that is spoken directly by the machine in use. The machine language is stored in a new file.
PROGRAM EXECUTION
The preprocessor takes your source code and following certain directives that you give it tweaks it in various ways before compilation. A directive is given as a line of source code starting with the # symbol The preprocessor works in a very crude, word-processor way, simply cutting and pasting it doesnt really know anything about C!
Your source code Enhanced and obfuscated source code Object code
Preprocessor
Compiler
10
SEPARATE COMPILATION Advantage: Quicker compilation When modifying a program, a programmer typically edits only a few source code files at a time. With separate compilation, only the files that have been edited since the last compilation need to be recompiled when re-building the program. For very large programs, this can save a lot of time.
11
PROGRAM COMPILATION
A C program consists of source code in one or more files Each source file is run through the preprocessor and compiler, resulting in a file containing object code Object files are tied together by the linker to form a single executable program
Source code file1.c Source code file2.c Libraries .h or .lib Preprocessor/ Compiler Preprocessor/ Compiler Object code file1.o Object code file2.o