Mastering CMake from Beginner to Advanced (3): Functions and Parameter Passing

Mastering CMake from Beginner to Advanced (3): Functions and Parameter Passing

In-depth analysis<span>function()</span> and <span>macro()</span> differences, mastering variable arguments and cross-platform compilation practical applications. 1. <span><span>function()</span></span> and <span><span>macro()</span></span> essential differences 1.1 Scope and Variable Passing <span>function()</span>: Local Scope: Variables (including parameters) defined inside the function are only valid within the function and are not visible externally. Parameter Passing: Passed by value, modifications to parameters within the … Read more

Basics of Makefile in C Compilation

Basics of Makefile in C Compilation

When compiling a large project, there are often many target files, library files, header files, and the final executable file. There are dependencies between different files. For example, when we compile using the following commands: $gcc -c -o test.o test.c $gcc -o helloworld test.o The executable file helloworld depends on test.o for compilation, while test.o … Read more

Essential Embedded C Language Macro Techniques You Must Know

Essential Embedded C Language Macro Techniques You Must Know

Word Count: 2000 Practicality Index: ⭐⭐⭐⭐⭐ 01 Macro Print Function In our embedded development, using printf to print some information is a common debugging method. However, when the amount of printed information is large, it can be difficult to know which information is printed in which function. Especially for printing exceptions, we need to quickly … Read more

Common Uses of Preprocessor Directives in Embedded Software

Common Uses of Preprocessor Directives in Embedded Software

Many excellent codes utilize preprocessor directives to enhance their functionality. Today, we will discuss the content related to preprocessor directives. The common preprocessing directives are as follows: # directive, has no effect #include includes a source code file #define defines a macro #undef undefines a macro #if if the given condition is true, compile the … Read more

How to Add Built-in Macros to riscv-gcc

The riscv-gcc tool includes some built-in macro parameters. We can use these built-in macros to determine the behavior of the compiler. 1. Viewing GCC Built-in Macro Parameters Here, we take the riscv-nuclei-elf-gcc toolchain released by Chipone Technology as an example. Using the following command, we can get the built-in macro parameters of this tool: riscv-nuclei-elf-gcc … Read more