C++ Programming Tips: How to Effectively Use Exception Specifications as a Double-Edged Sword

C++ Programming Tips: How to Effectively Use Exception Specifications as a Double-Edged Sword

Exception specifications were introduced in C++98 and replaced by noexcept in C++11. Exception specifications serve to restrict the exceptions thrown by functions, enhancing program readability.However, if a function throws an exception that is not allowed by its exception specification, the program will call the unexpected function, which by default calls terminate, causing the program to … Read more

Understanding eBPF Timers in Linux

Understanding eBPF Timers in Linux

eBPF Timers v5.15 Timers allow eBPF programs to schedule the execution of an eBPF function at a later time. Use cases for this functionality include garbage collection of mapping values or performing periodic checks. For example, if the TTL (Time to Live) of a DNS record has expired, we may want to remove those records … Read more

Comparison of Communication Methods Between Embedded System Modules

Comparison of Communication Methods Between Embedded System Modules

Follow our official account to keep the embedded knowledge flowing! 1. Global Variables Global variables are often regarded as “bad design,” but in embedded systems, they are the most performant communication method. The key is not to avoid their use, but rather to design them correctly. The issue with global variables is not performance, but … Read more

Analysis of the Underlying Principles of std::function in C++: How to Use It with Callback Functions?

Analysis of the Underlying Principles of std::function in C++: How to Use It with Callback Functions?

Have you ever experienced this: writing a GUI button click callback using function pointers is quite cumbersome — trying to bind a lambda with captures results in an error, and binding a class member function requires passing the ‘this’ pointer, leading to increasingly messy code; until you switch to std::function, and suddenly realize that whether … Read more

Exploring Function Pointers in C Language (Part 3)

Exploring Function Pointers in C Language (Part 3)

Continuing the discussion on pointers in C language, one of the powerful features is the function pointer, which brings unprecedented flexibility and extensibility to your code. What is a Function Pointer? A function pointer, as the name suggests, is a pointer variable that points to a function. It stores the memory address of a function, … Read more

C Language Callback Functions: Essential Skills to Enhance C Techniques

C Language Callback Functions: Essential Skills to Enhance C Techniques

Click the blue textFollow us Due to changes in the public account’s push rules, please click “View” and add “Star” to receive exciting technical shares at the first time. Source from the internet, please delete if infringing 1. Function Pointers Before discussing callback functions, we need to understand function pointers. As we know, the soul … Read more

Function Pointers and Callback Functions in C Language

Function Pointers and Callback Functions in C Language

In the previous article, we discussed the declaration and definition of pointers and other basic concepts. However, our understanding of pointers is still insufficient, so in this lesson, we will continue to learn about pointers. To reinforce our understanding, let’s first look at a classic pointer example code. Can you find the correct answer?Question: Now … Read more

Learning Notes on Callback Functions in C Language

Learning Notes on Callback Functions in C Language

Today, I studied callback functions and recorded some of my thoughts based on articles from experts online. I will continue to write about the subsequent topics. What is a callback function? A callback function is a function that is called through a function pointer. If you pass the pointer (address) of a function as a … Read more

Learning Notes on Callback Functions in C: Concepts, Classifications, and Embedded Applications

Learning Notes on Callback Functions in C: Concepts, Classifications, and Embedded Applications

1. What is a Callback Function? A Callback Function is a programming pattern implemented through function pointers, characterized by the following core features: Passing Method: Function A (the callback function) is passed as a parameter to Function B. Calling Relationship: Function B calls Function A under specific conditions, in contrast to the traditional top-down calling. … Read more