Why are C macros not type-safe?

后端 未结 7 1768
礼貌的吻别
礼貌的吻别 2021-02-18 16:01

If have encountered this claim multiple times and can\'t figure out what it is supposed to mean. Since the resulting code is compiled using a regular C compiler it will end up b

7条回答
  •  臣服心动
    2021-02-18 16:18

    Macros aren't type safe, because they were never meant to be type safe.

    The compiler does the type checking after macros had been expanded.

    Macros and there expansion are meant as a helper to the ("lazy") author (in the sense of writer/reader) of C source code. That's all.

提交回复
热议问题