如何使用带有2个变量的宏。

huangapple go评论119阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月6日 02:34:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76409145.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定