Developers Club geek daily blog

Design and evolution of language C ++: excerpts

2 years, 11 months ago
In comments to transfer "30 years With ++" were noticeable that not all stages of evolution of language are equally well-known, sometimes at all there is no idea of an origin and development of this or that element of syntax or the corresponding semantics. Perhaps, this note will possible to interest readers will address for a long time not the new book of the author of language for the purpose of forming of broader picture about C ++. The book tells as there was its development that exerted impact on this process and why the preference was given to one approaches instead of others.

Read more »

Static analysis of printf-like of functions in Xi by means of libclang

2 years, 11 months ago
In comparison with many modern languages the Xi language often seems extremely primitive and unsafe. And one of frequent claims to language is the impossibility of access from a code to its internal representation. In other languages it is traditionally performed by mechanisms, like reflections, and it is quite convenient in application.

Nevertheless, with the advent of libclang, it is possible to write own analyzers and generators of a code directly to compile time, fixing rather big set of problems at early stages of work. The combination of instruments of static analysis of a vista shot (coverity, clang-scan), analysis tools for the specific project, and also discipline of writing of a code allows to improve much more quality and code safety, written on Xi. Of course, it will not give guarantees what haskell or even rust gives, but allows to optimize significantly development process, especially in a case when to rewrite the huge project in other language is an unreal task.

I would like to share experience of creation of a plug-in of static analysis of format argument for the functions similar to printf in this article. During writing of a plug-in, I had to rummage much in source codes and doxygen of documentation libclang therefore I considered useful to make some overview for those who want to step into this thorny road, but for the present it is not confident in expediency of a waste of time on collection of information. In article there will be no pictures, and even pictures of the vomiting unicorns, forgive.

Read more »

Where to be to type: on the right or at the left?

2 years, 11 months ago
Having somehow seen the next article on Habré devoted for me absolutely modern and to the Go novel language, decided to try what the animal is and what it is eaten with (Generally of course, the logo was pleasant). Of course, language has many opportunities and is rather convenient. But that surprised me at once, it is the principle of the declaration of variables, other than C-like languages, namely the type of variables is described to the right of a variable name. As the person who almost grew up on With it was surprising to me. Then I of course remembered Pascal that there too the variable type was on the right. Having become interested in this question, I tried to understand why this or that syntax of type declaration of variables in these 2 languages is used.

Read more »

30 years With ++

2 years, 11 months ago
On October 14 this year one of the most important anniversaries of the world of programming – the 30 anniversary of language C ++ took place. During this time it won huge popularity and still remains to one of the most demanded and widely used programming languages in the world.

In this regard anniversary we bring to your attention transfer of interview with the founder of language Byyorn Straustrup.

Read more »

The book "we Program Arduino: Basics of sketches"

2 years, 12 months ago
Hi, Habrozhiteli!
We had a book innovation:

imageFor the first time in Russian there is a legendary best-seller of Simon Monk which many years hold the first places in Amazon ratings. You want to create the smart house or to program the robot? There is nothing more simply. Simon Monk not only will help to deal with delays, contacts and sensors, but also will show how to force all this artful design of wires and payments to do that it is necessary for you. Arduino — it is not as difficult as it seems at first sight. You will be subdued by the opening opportunities at once.

Read more »

To build in JSON Embedded? As easy as shelling pears

3 years ago

Not so long ago I had had need to load application configuration at very limited resources. There was no access, practically, to any standard functions of C. It was very lucky that there were standard functions on work with memory of malloc () / free ().

There was the following situation: the configuration is read out from the file at loading of the application on system with limited resources. The configuration has to be edited easily on the normal computer up to that it will be necessary to correct quickly some value directly on object at demonstration for the customer.

From this it is possible to draw conclusion that is necessary or:
  1. To write the editor of binary format.
  2. To use text format.

Read more »

Rules of defensive programming on With: last, real and future

3 years ago
Luxoft Training suggests you to get acquainted with transfer of article "C Secure Coding Rules: Past, Present, and Future" Roberta S. Sikorda, professor of software engineering institute (SEI) Carnegie-Mellon, author of books "The CERT C Coding Standard, Second Edition" and "Secure Coding in C and C ++, Second Edition".

Read more »

Check of Wine: A year later

3 years ago

Slightly more than a year ago for writing of article about verifications of the project with the help of PVS-Studio the Wine project has been taken. Article is written, authors have been notified and even have asked the full report of check by the analyzer, on what have received affirmative answer. Recently we were written by one of developers of the project. In article it will be told about our communication, the done work of design team of the Wine project on improvement of code and that else it is necessary to make.

Read more »

4 ways to write to the secure page

3 years ago
Execution of record on hardware write-protected memory address in architecture of x86 means. And how it becomes in the Linux operating system. And, naturally, in Linux kernel mode because in user space, such tricks are prohibited. Happens, whether know, irresistible desire to write in the protected area … when you sit down to write virus or trojan …

Description of problem

… and if it is serious, the record problem in write-protected pages of random access memory arises from time to time when programming modules of kernel under Linux. For example, at modification of the selector table of system calls of sys_call_table for modification, embedding, implementation, substitutions, interception of system call — in different publications call this action on miscellaneous. But not only for these purposes … In very summary the situation looks so:

  • In architecture of x86 there is protection gear which in attempt of record in write-protected pages of memory leads to excitation of exception.
  • Access rights to the page (permission or prohibition of record) are described beaten _PAGE_BIT_RW (1) in the structure corresponding to this page like pte_t. Reset of this bit forbids record in the page.
  • From the processor control by protection of record the bit of X86_CR0_WP (16th) of the system managing register CR0 manages — at the set this bit attempt of record in the write-protected page excites exception of this processor.

Read more »

Objects of the zero size

3 years ago
In what difference between the following pairs of lengths and pointers?

size_t len1 = 0;
char *ptr1 = NULL;

size_t len2 = 0;
char *ptr2 = malloc(0);

size_t len3 = 0;
char *ptr3 = (char *)malloc(4096) + 4096;

size_t len4 = 0;
char ptr4[0];

size_t len5 = 0;
char ptr5[];

In many cases all five expressions will lead to one result. In others – their behavior can cardinally differ. One of obvious distinctions consists in opportunity to transfer the pointer for its release, but we will not consider it.

The first case interesting, but too strongly differs from others therefore so far we will postpone it.


The behavior of malloc (0) is defined by standards. It is possible to return the null or unique pointer. The second option in many implementations is executed by internal increase in length at unit (which then it is usually rounded to 16). By rules, it is impossible to dereference such pointer, but usually some bytes after all are placed and therefore such program will not fall.

Return of NULL results in possibility of interesting bug. Often return of NULL from malloc is regarded as error.

Read more »