Why does #define not require a semicolon?

前端 未结 7 1018
无人及你
无人及你 2020-11-27 21:03

I was writing some test code in C. By mistake I had inserted a ; after a #define, which gave me errors. Why is a semicolon not req

7条回答
  •  孤街浪徒
    2020-11-27 21:38

    Because that is how the syntax was decided for the precompiler directives.

    Only statements end with a ; in c/c++, #define is a pre-processor directive and not a statement.

提交回复
热议问题