From C++ Function Pointers to Function Objects

From C++ Function Pointers to Function Objects

In the previous article, we introduced the relevant applications of function pointers and stated that they are a low-level language construct inherited from C. In C++, objects are used as a more powerful method than C-style function pointers, and these objects are called function objects. Similar to function pointers, function objects behave like functions, but … Read more

Modular Programming Concepts in Embedded C

Modular Programming Concepts in Embedded C

Modular Programming Concepts Modular programming is a programming method that breaks down a program into independent, reusable modules. Each module implements a specific function, and modules interact through clearly defined interfaces. This concept helps improve the maintainability, readability, and scalability of the code. Preprocessing, Compilation, Assembly, Linking Preprocessing: Processes preprocessor directives in the source code, … Read more

C Language Special Topic: 8. Function Pointers

C Language Special Topic: 8. Function Pointers

In C language, functions are also a type of “object”, which have addresses in memory. Therefore, it is possible to define pointers to functions, which can be used for dynamic calls, callback handling, building function tables, etc. Mastering function pointers is key to understanding the “low-level abstraction” and “modular programming” in C language. 1. Basic … Read more

Best Programming Model for Low Power Design: Asynchronous Programming

Best Programming Model for Low Power Design: Asynchronous Programming

Asynchronous programming can create efficient programs that are fast and resource-saving. It allows high concurrency in a single-threaded environment and can implement TCP/IP protocol stacks without an operating system. Fast and resource-efficient, it can keep power consumption at the lowest level, making asynchronous programming the best programming model for low power design. Three Realms There … Read more

Function Pointers and Callback Mechanism in C++: Write More Flexible Code

Function Pointers and Callback Mechanism in C++: Write More Flexible Code

Hello everyone! Today we are going to talk about a particularly practical and interesting topic—function pointers and callback mechanisms. In C++, function pointers are a tool that makes your code more flexible, allowing you to dynamically choose which function to execute at runtime. The callback mechanism is a classic application of function pointers, widely used … Read more