开发者

What's the purpose of `qt_noop`

开发者 https://www.devze.com 2022-12-31 08:19 出处:网络
I just found the exi开发者_Go百科stence of qt_noop() define in the qglobal.h as: inline void qt_noop() {}

I just found the exi开发者_Go百科stence of qt_noop() define in the qglobal.h as:

inline void qt_noop() {}

What's the point of it?


The "noop" name is short for "no operation", meaning it is a place-holder function that does nothing.

You may also know NOP, which exists in assembly-language.

I know it's used internally in some macros that should do something only for debug builds, for example:

#  ifndef QT_NO_DEBUG
#    define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
#  else
#    define Q_ASSERT(cond) qt_noop()
#  endif
#endif
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号