英文:
How to use a macro with 2 variables
问题
The variable_3 is actually a parameter which can be changed, I don't understand how it can affect after a software is built.
variable_3实际上是一个可以更改的参数,我不明白它在软件构建后如何影响。
英文:
Can someone help me understand the below macro?
#define variable_1 tF32 const variable_2 = variable_3
The variable_3 is actually a parameter which can be changed, I don't understand how it can affect after a software is built.
答案1
得分: 1
预处理器在实际编译代码之前,在编译过程中起作用。它根据定义的宏执行文本替换。每当预处理器在代码中遇到标记 variable_1
时,它将用 tF32 const variable_2 = variable_3
进行替换。在替换时会使用 variable_3
的值。
一旦代码编译完成并生成可执行文件,宏定义将不再相关。因此,在软件构建后对 variable_3
进行的任何更改都不会影响已经编译的可执行文件。使用这种宏的目的是定义常用的代码模式并在编译时提供配置选项。variable_3
的值是在替换时确定的,根据宏的使用上下文而定。
英文:
The preprocessor works during the compilation process, before the actual compilation of the code. It performs textual substitution based on the defined macros. Whenever the preprocessor encounters the token variable_1
in the code, it will replace it with tF32 const variable_2 = variable_3
. The value of variable_3
will be used at the time of substitution.
Once the code is compiled and the executable is generated, the macro definitions are no longer relevant. Therefore, any changes made to variable_3
after the software is built will not affect the already compiled executable. The purpose of using such macros is to define commonly used code patterns and provide configuration options at compile-time. The value of variable_3
is determined at the time of the substitution, based on the context in which the macro is used.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论