Thread: What is the purpose of this (void)

  1. #1
    Registered User
    Join Date
    Jul 2020
    Posts
    2

    What is the purpose of this (void)

    What is the purpose of this (void) in the following code:

    Code:
    int functionA( structA *testresults, int test)
    {
        // Some code
    
       (void)testresults;
    
       // Some code
    
    }

  2. #2
    Registered User
    Join Date
    Feb 2019
    Posts
    765
    This is a null expression. The use of (void) there is an attempt to avoid a compiler warning... Not really necessary (because the expression is null, but valid).

  3. #3
    Registered User
    Join Date
    Jul 2020
    Posts
    2
    Quote Originally Posted by flp1969 View Post
    This is a null expression. The use of (void) there is an attempt to avoid a compiler warning... Not really necessary (because the expression is null, but valid).
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: invalid conversion from 'const void*' to 'void*'
    By Wahidin Wahid in forum C++ Programming
    Replies: 10
    Last Post: 04-17-2012, 02:17 AM
  2. error invalid conversion from ‘const void*’ to ‘void*’
    By Wahidin Wahid in forum C Programming
    Replies: 3
    Last Post: 03-27-2012, 08:18 PM
  3. Replies: 12
    Last Post: 03-27-2009, 02:36 PM
  4. Passing a variable in void to another void function
    By stevedawg85 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 06:17 PM
  5. Invalid conversion from 'const void*' to 'void*' error
    By prawntoast in forum C Programming
    Replies: 3
    Last Post: 05-01-2005, 10:30 AM

Tags for this Thread