---
title: NOP (code)
slug: nop-code
qid: 
snapshot: enwiki-001373899342
content_hash: 
license: CC BY-SA 4.0
source: https://en.wikipedia.org/w/index.php?oldid=1373899342
tags: [125876068, 130285717, 23118434, 23603337, 24745113, 25557078, 32300770, 55471075]
---

# NOP (code)

> [!note] Provenance
> Snapshot `enwiki-001373899342` · content root `…`
> Derived from <https://en.wikipedia.org/w/index.php?oldid=1373899342> · Licensed CC BY-SA 4.0

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 &lt;assert.h&gt; 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 = () => {};
