Pull to refresh
119.04

C *

General-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations

Show first
Rating limit
Level of difficulty

Tree-sitter and Preprocessing: A Syntax Showdown

Level of difficultyMedium
Reading time5 min
Views608

According to the description,


Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited.

But how does Tree-sitter handle languages that require a preprocessing stage?

Read more →
Total votes 2: ↑2 and ↓0+2
Comments1

How to build and run calculator from Windows XP using GCC x64?

Level of difficultyHard
Reading time63 min
Views935

Hi Everyone!

In this article we a little bit will analyze of code of Windows XP and will compile the calculator application using GCC x64 in Windows 10 environment. We will look what kind of errors I faced during the build and the methods how to solve them. At the end we will launch the build of the calc.exe application.

Have a nice reading!

Read more
Total votes 6: ↑6 and ↓0+7
Comments0

How to send messages over sockets and create your own messanging protocols in C++

Level of difficultyMedium
Reading time28 min
Views6K

Network programming in C++ can be challenging. But even a greater challenge is to find educational content that will arm you with the knowledge on how to apply your networking skills in real applications.

In this article you can learn the basics of socket communication and many ways how you can design your internal messaging protocols.

Read more
Total votes 2: ↑2 and ↓0+2
Comments3

Setup of Qt Creator for programming and debugging of STM32 microcontrollers

Level of difficultyMedium
Reading time9 min
Views2.3K

Currently I am investigating firmware development for STM32 microcontrollers and I would like to share with you my experience for doing it in Qt Creator IDE.

There are a lot of IDEs, which are used for firmware development of STM32. Some of them, being quite comfortable, have restrictions for trial license. For example, the one of the most known IDE, IAR Embedded, suggests either a limited amount of product usage time (30 days) or the limited firmware size of 32 MB, which is not too much.

Within this scope of the publication, we investigate the method of setting up an environment that allows one to develop the full value of the STM32 firmware in Qt Creator.

Read more
Rating0
Comments0

Review of mini-book «60 terrible tips for a C++ developer»

Level of difficultyEasy
Reading time6 min
Views1.3K

I wrote a small e-book about terrible tips for C++ developers. Actually, it describes bad programming practices and explains why it's better to avoid them. However, every chapter of this mini-book starts with a terrible tip — just for fun.


60 terrible tips for a C++ developer


By the way, these tips may seem artificial but believe me, they are based on the real experience. In other words, the described terrible tips occur in developers' lives — that's why it's worth discussing them. First of all, this book will be useful for junior developers. But more skilled C++ developers can also find interesting and useful tips.


Even though it's a mini-book, it clearly does not fit into the Habr format. Too many words. So, I decided to write here the review. Here is the link to find the full version of the mini-book: 60 terrible tips for a C++ developer.


If you still hesitate whether to read it or not, below you will find a list of terrible tips that will be discussed in the mini-book.


View the terrible tips:

Read more →
Total votes 8: ↑5 and ↓3+4
Comments3

APRS. AFSK modulator from Flipper Zero

Level of difficultyMedium
Reading time7 min
Views5.3K

There is such an interesting data transfer protocol - APRS. A lot has already been told about him on the Internet. There will be no in-depth theoretical material here. This article will describe how to create your own "pocket" AFSK modulator. In the following articles there will be instructions for going on the air and for creating a simple demodulator. Which will allow you to accept APRS packages and display information on the display right on the street. Everything will be implemented for Flipper Zero. If you don't have this gadget yet, then don't worry and try everything on the great and terrible Arduino. It is very interesting to transmit information at a distance "with your own hands".

Read more
Total votes 3: ↑3 and ↓0+3
Comments2

Pixel image rotation

Level of difficultyEasy
Reading time13 min
Views1.3K

Brief problem formulation

The program accepts as input the absolute path to the image in the bmp extension and the path where you save the result of the work. Then, it rotates the image by 90 degrees counterclockwise. Afterwards, the program saves the new image.

The program is executed on C.

Read more
Total votes 4: ↑2 and ↓2+3
Comments0

Audio API Quick Start Guide: Playing and Recording Sound on Linux, Windows, FreeBSD and macOS

Reading time35 min
Views19K

Hearing is one of the few basic senses that we humans have along with the other our abilities to see, smell, taste and touch. If we couldn't hear, the world as we know it would be less interesting and colorful to us. It would be a total silence - a scary thing, even to imagine. And speaking makes our life so much fun, because what else can be better than talking to our friends and family? Also, we're able to listen to our favorite music wherever we are, thanks to computers and headphones. With the help of tiny microphones integrated into our phones and laptops we are now able to talk to the people around the world from any place with an Internet connection. But computer hardware alone isn't enough - it is computer software that really defines the way how and when the hardware should operate. Operating Systems provide the means for that to the apps that want to use computer's audio capabilities. In real use-cases audio data usually goes the long way from one end to another, being transformed and (un)compressed on-the-fly, attenuated, filtered, and so on. But in the end it all comes down to just 2 basic processes: playing the sound or recording it.

Today we're going to discuss how to make use of the API that popular OS provide: this is an essential knowledge if you want to create an app yourself which works with audio I/O. But there's just one problem standing on our way: there is no single API that all OS support. In fact, there are completely different API, different approaches, slightly different logic. We could just use some library which solves all those problems for us, but in that case we won't understand what's really going on under the hood - what's the point? But humans are built the way that we sometimes want to dig a little bit deeper, to learn a little bit more than what just lies on the surface. That's why we're going to learn the API that OS provide by default: ALSA (Linux), PulseAudio (Linux), WASAPI (Windows), OSS (FreeBSD), CoreAudio (macOS).

Read more
Rating0
Comments0

Alternate of Packed-Binary Time Format

Reading time2 min
Views2.3K

The Real-Time Clock (RTC) Calendar Registers in STM32 microcontrollers implemented in Binary Code Decimal format (BCD) i. e., every two digits are represented by one byte (low digit in 0-3 bits and high digit 4-7 bits). At least there are 5 bytes required to store date and time data in a such format. There are cases when memory allocation for time stamp might become critical, e. g., the events log keeping in an extern non-volatile memory IC. Here the memory value for a single event (event serial number, timestamp, event parameters, and its CRC) is fixed and can compose up to 16 bytes. The maximum quantity of the events increasing, and time spent on a single operation reducing (for reserved power sources as supercapacitors and electrolytic capacitors is critical) can be achieved with less memory amount required for the event field.

Read more
Rating0
Comments0

Kernel Queue: The Complete Guide On The Most Essential Technology For High-Performance I/O

Reading time65 min
Views18K

When talking about high-performance software we probably think of server software (such as nginx) which processes millions requests from thousands clients in parallel. Surely, what makes server software work so fast is high-end CPU running with huge amount of memory and a very fast network link. But even then, the software must utilize these hardware resources at maximum efficiency level, otherwise it will end up wasting the most of the valuable CPU power for unnecessary kernel-user context switching or while waiting for slow I/O operations to complete.

Thankfully, the Operating Systems have a solution to this problem, and it's called kernel event queue. Server software and OS kernel use this mechanism together to achieve minimum latency and maximum scalability (when serving a very large number of clients in parallel). In this article we are going to talk about FreeBSD, macOS and kqueue, Linux and epoll, Windows and I/O Completion Ports. They all have their similarities and differences which we're going to discuss here. The goal of this article is for you to understand the whole mechanism behind kernel queues and to understand how to work with each API.

Read more
Total votes 7: ↑7 and ↓0+7
Comments1

PVS-Studio checks the code of Flipper Zero dolphin

Reading time12 min
Views1.7K

Flipper Zero + PVS-Studio


Flipper Zero is an open-source multi-tool for geeks and penetration testers. It so happened that the Flipper Zero project and the PVS-Studio analyzer crossed paths. A philosophical question: should we check the project, if the project developers have already started fixing errors? Let's try to do this.

Read more →
Total votes 3: ↑2 and ↓1+4
Comments0

Even small projects have bugs, or how PVS-Studio checked Blend2D

Reading time11 min
Views904

We often check large projects because it's easier to find bugs there. What if we try PVS-Studio on a small project? In this article we analyze Blend2D — a library for vector 2D graphics. Let's look at what we found.


0894_Blend2d/image1.png


Introduction


It's no secret that large projects have fascinating errors. It's not just "the larger the codebase is – the more errors we can find". It's also a known fact that the density of errors grows along with the codebase. That's why we love checking large projects — to treat you with a variety of "yummy" and tricky errors and typos. Besides, it's always interesting to search through a huge project with lots of dependencies, legacy code, and other stuff.


Today I'm moving away from this tradition. I decided to take a small project and see what PVS-Studio can find there. I chose Blend2D — branch master, commit c484790.

Read more →
Total votes 2: ↑1 and ↓1+1
Comments0

MISRA C: struggle for code quality and security

Reading time11 min
Views1.3K

A couple of years ago the PVS-Studio analyzer got its first diagnostic rules to check program code compliance with the MISRA C and MISRA C++ standards. We collected feedback and saw that our clients were interested in using the analyzer to check their projects for MISRA compliance. So, we decided to further develop the analyzer in this direction. The article covers the MISRA C/C++ standard and the MISRA Compliance report. It also shows what we already managed to do and what we plan to achieve by the end of the year.


0866_MISRA_C/image1.png

Read more →
Rating0
Comments0

Why do you need the MISRA Compliance report and how to generate one in PVS-Studio?

Reading time5 min
Views905

If you are strongly interested in MISRA and would like to understand whether your project meets one of the MISRA association's standards, there is a solution. It's name is MISRA Compliance. PVS-Studio has recently learned how to generate the MISRA Compliance report. This article describes how you can use this feature. This can make somebody's life better.

Read more
Rating0
Comments3

Linux kernel turns 30: congratulations from PVS-Studio

Reading time6 min
Views1.7K

On August 25th, 2021, the Linux kernel celebrated its 30th anniversary. Since then, it's changed a lot. We changed too. Nowadays, the Linux kernel is a huge project used by millions. We checked the kernel 5 years ago. So, we can't miss this event and want to look at the code of this epic project again.

Read more
Total votes 2: ↑2 and ↓0+2
Comments0

Authors' contribution