NOP (code)
≈ 2 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
In computer science, a NOP, no-op, or NOOP (pronounced "no op"; short for no operation) is a machine language instruction and its assembly language mnemonic, programming language statement, or computer protocol command that does nothing.
In computer science, a NOP, no-op, or NOOP (pronounced "no op"; short for no operation) is a machine language instruction and its assembly language mnemonic, programming language statement, or computer protocol command that does nothing. while (getchar() != '\n') {} alternatively, while (getchar() != '\n') ; or more tersely: while (getchar() != '\n'); The last form might generate a warning with some compilers or compiler options, as a semicolon placed after a parenthesis at the end of a line usually indicates the end of a function call expression. The above code continues calling the function getchar() until it returns a \n (newline) character, essentially fast-forwarding the current reading location of standard input to the beginning of next line. As well as a NOP statement, C programs will also sometimes use a NOP expression; for instance, the C standard requires that, should the NDEBUG macro be defined before the <assert.h> header, the assert() macro defined by it be defined as the expression ((void)0) . Similar techniques can be used by user code; for instance, consider the following code that defines a macro over the prefetch builtin function provided by GCC which is defined as a NOP expression if it's not available: ifdef __GNUC__ define prefetch(addr, ...) __builtin_prefetch((addr) __VA_OPT__ (,) __VA_ARGS__) else define prefetch(addr, ...) ((void)0) endif const noop = () => {};
Text derived from https://en.wikipedia.org/w/index.php?oldid=1373899342 under CC BY-SA 4.0; modifications have been made.