使用#define定义没有值的常量的目的是什么?(What is the purpose of using #define to define a constant with no value?)
使用#define定义没有值的常量的目的是什么?
如:
#define TOKEN
What is the purpose of using #define to define a constant with no value?
Such as:
#define TOKEN
最满意答案
您可以使用它来启用或禁用使用#ifdef或#ifndef某些代码,例如:
#ifdef TOKEN printf("token is defined"); #endif一个用途是在调试版本中切换日志记录。 另一个包括警卫 。
You can use it to enable or disable certain code using #ifdef or #ifndef, eg this:
#ifdef TOKEN printf("token is defined"); #endifOne use for this would be to toggle logging in debug builds. Another would be include guards.
更多推荐
发布评论