gregseth
gregseth

Reputation: 13408

What's the purpose of `qt_noop`

I just found the existence of qt_noop() define in the qglobal.h as:

inline void qt_noop() {}

What's the point of it?

Upvotes: 7

Views: 2968

Answers (1)

chalup
chalup

Reputation: 8516

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

Upvotes: 8

Related Questions