Skip to main content
added 2 characters in body
Source Link
Antti Haapala
  • 134.7k
  • 23
  • 297
  • 349

In some C project, I have seen this code:

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; /* some code not using `ud` or `osize` */ return ptr; } 

Do the two casts to void serve any purpose?

In some project, I have seen this code:

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; /* some code not using `ud` or `osize` */ return ptr; } 

Do the two casts to void serve any purpose?

In some C project, I have seen this code:

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; /* some code not using `ud` or `osize` */ return ptr; } 

Do the two casts to void serve any purpose?

Post Reopened by Antti Haapala c
Post Closed as "Duplicate" by Paul R c
Make it more explicit on the title that this is about function parameters.
Link
Ciro Santilli OurBigBook.com
  • 392.5k
  • 120
  • 1.3k
  • 1.1k

Why cast an unused function parameter value to void?

remove duplicate link
Source Link

Possible Duplicates:
casting unused return values to void
C++ What is the purpose of casting to void?

In some project, I have seen this code:

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; /* some code not using `ud` or `osize` */ return ptr; } 

Do the two casts to void serve any purpose?

Possible Duplicates:
casting unused return values to void
C++ What is the purpose of casting to void?

In some project, I have seen this code:

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; /* some code not using `ud` or `osize` */ return ptr; } 

Do the two casts to void serve any purpose?

In some project, I have seen this code:

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; /* some code not using `ud` or `osize` */ return ptr; } 

Do the two casts to void serve any purpose?

Post Reopened by CommunityBot
insert duplicate link
Source Link
Loading
Source Link
bastibe
  • 17.3k
  • 29
  • 99
  • 130
Loading