Is if(TRUE) a good idea in C?

后端 未结 17 3395
忘了有多久
忘了有多久 2021-02-19 01:19

In the C programming language, it is my understanding that variables can only be defined at the beginning of a code block, and the variable will have the scope of the block it w

17条回答
  •  长情又很酷
    2021-02-19 01:21

    I wouldn't call myself seasoned, but I'm kind of cringing.

    My issue with it is that the if statement would lead someone to believe that something is actually being evaluated...but at runtime, the macro is either true or false there's no change of it being something else. You should either include the code or not.

    If what you mean to do is something like #ifdef DEBUG then you should do that to indicate to the reader that this is debug code...

提交回复
热议问题