Why is #define bad and what is the proper substitute?

后端 未结 6 1138
情深已故
情深已故 2020-11-30 12:37
#define dItemName        L\"CellPhone\"
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 13:11

    Pointing to define doing what they where invented for as a failure is - well blaming a knife for cutting.

    If you dont not properly Name your defines with UPPERCASE_NAMES you will have troubles, but you will have those troubles anyway in C if you can not self-discipline your working style.

    You can not use const to generate dynamically rearranging systems, so its not suited for any embedded Application that is tailored pre-compile to usage.Const can only be assigned pre-evaluation constants, so not even other const Expressions.

    Just because a Tool doese not bow to the OO-Paradigm its does not suddenly become useless. Const is not equal replacement regarding functionality.

提交回复
热议问题