How does a compiler work in IDEs

Editors, compilers and integrated development environments

Editors, parsers and interpreters

One question: what does an editor have in common with a trowel?

Answering the question shouldn't be particularly difficult, as the trowel is just as much a hand tool of every bricklayer as an editor is a hand tool of every programmer. No bricklayer could erect a wall of bricks without materials and hand tools, and likewise no programmer could write source code for a program without a suitable editor. In this context, the bricklayer was only mentioned as a representative of all skilled trades in which no job would be really satisfactory without job-specific hand tools.

In the simplest case, a programmer will be satisfied with a pure text editor that can only display and save the ASCII character set or a related ANSI character set.
On the other hand, an editor that can highlight the syntax of the preferred programming language is much better suited, and an editor with syntax and brackets highlighting is even better. Especially with nested instructions, an editor with highlighted brackets can make troubleshooting much easier. Notepad ++, which is available free of charge, would be perfectly suitable as an all-round editor for Windows operating systems, for example, as it supports the syntax of a large number of markup, script and programming languages.

Depending on whether it is a markup language such as HTML or XML, a script language such as JavaScript or PHP, or a programming language such as C or C ++, at least one parser, interpreter or compiler is required. With the markup languages ​​HTML (Hypertext Markup Language) and XML (Extensible Markup Language) as well as the script language JavaScript, the client-side web browser slips into the role of the parser, although in previous years different browsers tended to have different interpretations when displaying web pages.
PHP (Hypertext Preprocessor) is, however, already parsed and interpreted by the web server. A small snippet of code could certainly be produced with any editor, inserted into an HTML page and tested on a server after a file has been uploaded, but an entire application cannot. In order to be able to test PHP applications on a PC, a server, a parser, an interpreter and a browser must be installed on the computer. In contrast to a markup language, the source code is not transmitted to a client-side browser, but first processed by a parser for the server-side interpreter and the finished HTML document (also other file types or file formats generated with PHP) transmitted to the browser. In addition to an Apache server, the XAMPP software package contains all the tools required to successfully test PHP applications on a home computer.

Preprocessors, compilers and linkers

The situation is completely different with the programming languages ​​C and C ++, as well as with many other high-level languages. With these programming languages, the source code of the program files is translated by a compiler into a program that can be read by machines. The process of translating in this process is called compilation. The compiler includes a preprocessor and a linker, the job of the preprocessor being to prepare source programs for compilation. This preparatory work of the preprocessor consists, among other things, in the integration of header files, in the removal of comments and superfluous empty spaces (Whitespace) from the source code, as well as in the evaluation and implementation of other preprocessor directives marked with a # hash.
After the preprocessor has prepared the source code of the program file, the compiler will translate it into machine-readable code and optimize this code in the course of the translation. If the compilation is successful, the compiler creates an object file. If a program consists of more than one program file, the compiler will also create more than one object file.
After the compiler, it is the turn of the linker. This merges several object files (if the program consists of several source files) and links to required runtime libraries, provided they contain functions declared in the corresponding header files. Functions that are contained in the C standard library, on the other hand, are not linked dynamically, but statically linked.

If the compilation went smoothly and the preprocessor, the compiler and the linker have reliably dealt with the respective obligations, a finished program with the extension "exe" should be available, at least insofar as it is a normal computer program. The situation is somewhat different with a program for a microcontroller, since the finished program is still made with the help of special hardware (Burner) must be transferred to the microcontroller in order to write it into its memory.

Graphic: Simplified representation of the compilation of a C program in the order program.c -> preprocessor -> compiler -> linker -> program.exe.

Integrated development environments

Integrated development environments for programming more extensive software applications are much better suited than individual compilers. Usually this includes an integrated development environment (called IDE for short) all necessary tools for programming and debugging, such as editor, compiler, linker, debugger and project manager. The free Visual C ++ Express Edition from Microsoft is very popular in the hobby sector. For the microcontroller sector, the MPLAB development environment from Microchip, which is also available free of charge, is worth mentioning. We would like you to have both IDEs (in the foreseeable future) introduce a little more detail.

Creating a C program with: