Is this a good way to embed debugging message in my program? (Macros)

前端 未结 3 973
说谎
说谎 2021-01-22 08:52

in the Debug.h file, I have the following:

#ifdef DEBUG_FLAG
    #define DEBUG(msg) std::cerr << #msg << std::endl
#else
    #define DEBUG(msg) for(;         


        
3条回答
  •  耶瑟儿~
    2021-01-22 09:46

    You don't need:

    #define DEBUG(msg) for(;;)

    at all. If you just have it as:

    #define DEBUG(msg)

    then the expression will be literally blank and won't require a semicolon at all.

    EDIT: And actually, having sole semicolons will not cause crashes or compiler errors.

提交回复
热议问题