Is it possible to use #define inside a function?

前端 未结 6 1949
野性不改
野性不改 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:47

    How does it work? All C/C++ files are first processed by... the preprocessor.

    It doesn't know anything about C nor C++ syntax. It simply replaces THIS_THING with ANOTHER THING. That's why you can place a #define in functions as well.

提交回复
热议问题