Is it possible to use #define inside a function?

前端 未结 6 1890
野性不改
野性不改 2021-01-07 22:38

For example, I saw source code like the following. Can we use #define in a function? How does it work? (more information: this code is what I copied from

6条回答
  •  囚心锁ツ
    2021-01-07 22:45

    You can use it inside a function, but it is not scoped to the function. So, in your example, the second definitions of a macro will be a redefinition and generate an error. You need to use #undef to clear them first.

提交回复
热议问题