Detailed Explanation of Calling Conventions in C/C++

Detailed Explanation of Calling Conventions in C/C++

In C/C++, a calling convention is a set of rules that defines how function parameters are passed, how the stack is maintained, and how return values are passed. This ensures that both the caller and the callee have a consistent understanding of the function call. Different calling conventions are suitable for different scenarios and primarily … Read more

Understanding extern “C” in C Language

Understanding extern "C" in C Language

In your C code, you might have seen something like the following: This seems fine, and you might think, “Well… yes, our code is always written this way, and we have never encountered any issues!” You are correct, as long as your header files have never been referenced by any C++ programs. What does this … Read more

Why Does Calling C Functions from C++ Always Result in Undefined Reference?

Why Does Calling C Functions from C++ Always Result in Undefined Reference?

In embedded development, we often encounter a situation where: the underlying driver library is written in C language (<span><span>.c</span></span> file), while the upper application or framework is in C++ (<span><span>.cpp</span></span> file). As a result, when we call it, we get: undefined reference to `xxx_function' Clearly, it is declared in the <span><span>.h</span></span> file and implemented in … Read more

Complete Guide to C/C++ Mixed Programming

Complete Guide to C/C++ Mixed Programming

👇 Follow our official account and select Star, to receive the latest content daily Introduction This article demonstrates the core technologies of C/C++ mixed programming through practical projects. It covers essential knowledge points from the basic extern "C" linkage specification to the complete compilation process, including name mangling, header file design, and CMake build. By … Read more

Understanding extern “C” in C Language

Understanding extern "C" in C Language

In your C code, you might have seen something like the following: This seems fine, and you might think, “Well… yes, our code is always written this way, and we’ve never encountered any issues with it.” You’re right, as long as your header files have never been referenced by any C++ programs. What does this … Read more