<p>Notice that without this cast, <code>data</code> would be unused in this function.  This is probably here for the purpose of preventing compiler warnings about unused variables, while keeping the argument in the function signature.</p>

CC BY-SA 3.0
2017-06-03T16:17:12.027Z
yes you are right, the cast `(void)` is necessary to avoid `gcc`'s warning. Thank you !
Sven Williamson
CC BY-SA 3.0
2017-06-03T16:14:10.043Z
2017-06-03T16:14:10.043Z
Jestin
<p>Without <code>(void) data;</code>, gcc will complain about <code>data</code> being an unused variable. This is used throughout the codebase, especially for context objects, to deal with parameters which are required for API/consistency reasons but not actually needed.</p>

CC BY-SA 3.0
2017-06-03T18:33:45.567Z
Many compilers also have some variant of `__unused(data);`, which, if available, is preferred.
abelenky
CC BY-SA 3.0
2017-06-03T16:09:58.577Z
2017-06-03T16:09:58.577Z
Andrew Poelstra
<p>The following code is contained in the file <code>secp256k1.c</code>:</p>

<pre><code>static void 
default_illegal_callback_fn( 
  const char* str, 
  void* data) 
{
  (void)data;
  fprintf(stderr, "[libsecp256k1] illegal argument: %s\n", str);
  abort();
}
</code></pre>

<p>Could someone explain the purpose of the line <code>(void)data;</code>? I am pretty sure there is one, but I can't figure out what it is :(</p>

<secp256k1>
C secp256k1: What is the purpose of the idiom '(void)data;'?
Sven Williamson
# C secp256k1: What is the purpose of the idiom '(void)data;'?

(Asked by: username_0 on 2017-06-03)

The following code is contained in the file `secp256k1.c`:

```
static void 
default_illegal_callback_fn( 
  const char* str, 
  void* data) 
{
  (void)data;
  fprintf(stderr, "[libsecp256k1] illegal argument: %s\n", str);
  abort();
}

```

Could someone explain the purpose of the line `(void)data;`? I am pretty sure there is one, but I can't figure out what it is :(

**Tags:** secp256k1


---

## 2 answers

### Answer by username_2 on 2017-06-03. Score: 7 | Accepted answer

Without `(void) data;`, gcc will complain about `data` being an unused variable. This is used throughout the codebase, especially for context objects, to deal with parameters which are required for API/consistency reasons but not actually needed.

> **Comments:**
> **username_3**: Many compilers also have some variant of `__unused(data);`, which, if available, is preferred.  

---

### Answer by username_1 on 2017-06-03. Score: 3

Notice that without this cast, `data` would be unused in this function. This is probably here for the purpose of preventing compiler warnings about unused variables, while keeping the argument in the function signature.

> **Comments:**
> **username_0**: yes you are right, the cast `(void)` is necessary to avoid `gcc`'s warning. Thank you !  

---

