U02s02 Programmingtools
U02s02 Programmingtools
C programming tools
Stefano Quer, Pietro Laface, and Stefano Scanzio
Dipartimento di Automatica e Informatica
Politecnico di Torino
skenz.it/os [email protected]
Operating Systems 2
Programming languages
Programming languages
IEEE Spectrum
Top Programming Languages
2022
Operating Systems 4
Programming languages
PYPL Index e Stack Overflow
Settembre 2022
Operating Systems 5
IDE
https://www.geeksforgeeks.org/
7-best-ides-for-c-c-plus-plus-
developers-in-2022/
Settembre 2022
Operating Systems 6
IDE
Tool Comments
Eclipse Written in JAVA and developed by IBM. It supports C, C++,
C#, Java, Javascript, COBO; Perl, Python, etc.
Visual Studio Written in C++ and developed by Microsoft. It supports C,
C++, C#, CSS, Go, HTML, Java, JavaScript, Python, PHP,
TypeScript and other.
NetBeans Free open source, developed by Apache Software
Foundation. Recommended for students or beginners and
C/C ++
CLion Developed by Jetbrains for programmers in C++, best cross-
platform platform (macOS, Linux, Windows integrated with
Cmake); it supports Kotlin, Python, Swift, etc.
Code::Blocks Open-source C/C++ IDE developed using wxWidgets, a
toolkit GUI; it supports C, C++ e Fortran
CodeLite Free and open-source for C++; one of the best IDE for code
refactoring; supported by Windows and Mac
QtCreator It requires commercial license for its complete version; it is supported
by Windows, Linux, and macOS
Operating Systems 7
Editor
https://www.linuxtechi.com/top-10-text-editors-for-linux-
desktop/
Settembre 2022
Operating Systems 8
Editor
Tool Comments
VIM VI Improved. Default editor UNIX/Linux; present
everywhere. Difficult but widely configurable.
Geany Editor for Linux desktop integrable with the development
tool GTK+
Sublime Text editor and development environment. It supports
different languages (automatic markup)
Brackets Produced by ADOBE in 2014 for Linux. Developed with
HTML; CSS and JavaScript. Light.
Gedit Default editor for the GNOME desktop. Simple user
interface. Light.
VS Code Visual Studio Code, Microsoft, for Windows, UNIX/Linux,
Mac. Very powerfull and usefull editor.
Nano Similar to the editor Pico, released in 2000, but with several
additional features. It allows only a «line interface»
Emacs One of the older Linux editors; developed by Richard
Stallmann (https://youtu.be/jUibaPTXSHk), funder of GNU.
Completelly developed in LISP and C.
Operating Systems 9
Text editor
Present in all BSD and Unix systems (and also in
embed systems)
Developed since 1976
Last version (8.1) in 2018
Base version (Vi)
Is not functional for extensive file editing
Very useful if other editors cannot be used, or give
some problem
e.g., remote editing
Operating Systems 10
Documentation
Local help : man vim
Online resources: http://www.vim.org/docs.php
Resources in PDF: ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf
Operating Systems 13
Editor: emacs
Editor: emacs
Available for
GNU, GNU/Linux
FreeBSDm, NetBSD, OpenBSD
Mac OS X
MS Windows
Solaris
Operating Systems 16
Editor: emacs
Advantages
Many features, more powerful than the simple text
editor
Fully customizable
Fast execution of complex operations
Disadvantages
Slow learning curve
Written in Lisp
Operating Systems 17
Editor: emacs
Documentation
Local help : man emacs
Online resources : http://www.gnu.org/software/emacs/manual/emacs.html
Resources in PDF: http://www.gnu.org/software/emacs/maanual/pdf/emacs.pdf
Operating Systems 18
Compiler
GCC
G++
Makefile
Configure
Debugger
GDB
Operating Systems 19
Compiler: gcc
Examples
gcc options
gcc options
Do not insert spaces
-Idir
Specify further directories where searching header
files
More than one directory can be specified (-Idir1 –
Idir2 …)
-lm
Specifies to use the math library
-Ldir
Specifies the search directories for pre-existing
libraries to be linked
Operating Systems 23
Example 1
Makefile
Makefile
Make
Provides a convenient tool to automate the
compilation and linker steps
Help
Extremely flexible
man make instrument, but its main
strength is the verification
of dependencies
Operating Systems 25
Makefile
Make options
Makefile options
Makefile format
Tabulation character
target: dependency
<tab>command
A Makefile includes
Empty lines
They are ignored
Lines starting with "#"
They are comments, and consequently ignored
Lines that specify rules
Each rule specifies a target, some dependencies,
and actions; it can occupy one or more lines
Very long lines can be splitted by inserting the "\"
character at the end of the line
Operating Systems 29
Makefile format
target: dependency
<tab>command
Makefile format
A makefile consists of "rules" like this:
target: dependency
<tab>command
target:
<tab>gcc –Wall –o myExe main.c -lm
project2:
<tab>gcc –Wall –o project2 myFile2.c
The Makefile specifies more rules
Need to choose which is the target to execute
The default consists in the execution of the first
target
Executing the command
make
The target project1 is executed
make project2
The target project2 is executed
Operating Systems 33
clean:
<tab>rm –rf *.o *.txt
Specify more rules
Rules have no dependencies
The first target executes two commands (gcc and
cp)
This first target is executed with the commands
● make
● make target
Operating Systems 34
clean:
<tab>rm –rf *.o *.txt
Example 4: dependencies
target: file1.o file2.o
<tab>gcc –Wall –o myExe file1.o file2.o
Example 4: dependencies
target: file1.o file2.o
<tab>gcc –Wall –o myExe file1.o file2.o
Example 5: Macro
CC=gcc Definition of macro:
FLAGCS=-Wall -g macro=name
SRC=main.c bst.c list.c util.c (with or without spaces)
project: $(SRC)
<tab>$(CC) $(FLAGS)–o project $(SRC) –lm
Use of the macro:
$(macro)
Example 6: Multi-Folder
Debugger: gdb
Debugger: gdb
Action Command
Execution commands run (r)
next (n)
next <NumberOfSteps>
step (s)
step <NumberOfSteps>
stepi (si)
finish (f)
continue (c)
Breakpoint commands info break
break (b), ctrl-x-blank
break LineNumber
break FunctionName
break fileName:LineNumber
disable BreakpointNumber
enable BreakpointNumber
Operating Systems 43
Debugger: gdb
Action Command
Print commands print (p)
print expression
display expression
Stack operations down (d)
up (u)
Info args
Info locals
Code listing commands list (l)
list LineNumber
list FirstLine, LastLine
http://darkdust.net/files/GDB%20Cheat%20Sheet.pdf