Skip to main content

C_VOID_RETURNS

Static C_VOID_RETURNS 

Source
pub static C_VOID_RETURNS: &Lint
Expand description

The c_void_returns lint detects the use of core::ffi::c_void as a return type.

§Example

use std::ffi::c_void;

unsafe extern "C" {
    fn foo() -> c_void;
}

{{produces}}

§Explanation

c_void is designed for use through a pointer, equivalent to C’s void* type. It is a mistake to use it directly as a return type, and calling extern functions declared as such may result in undefined behavior. C functions that return void must be declared to return () in Rust (omitting the return type implicitly returns ()).